-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.cpp
More file actions
73 lines (63 loc) · 1.26 KB
/
Card.cpp
File metadata and controls
73 lines (63 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//George Vargas
//CECS 282-07
//Prog 1-Solitaire Prime
//Feb 12, 2020
#include "Card.h"
#include <iostream>
using namespace std;
/**
* The default constructor.
*/
Card::Card() {
rank = '?';
suit = '?';
}
/**
* The overloaded constructor.
* @param r Rank
* @param s Suit
*/
Card::Card(char r, char s) {
rank = r;
suit = s;
}
/**
* This sets the card.
* @param r Rank
* @param s Suit
*/
void Card::setCard(char r, char s) {
rank = r;
suit = s;
}
/**
* This casts the rank char type into an int value
* @return This returns the numerical value of the card object.
*/
int Card::getValue() {
if (rank < 11)
return rank;
else if (rank > 10)
return 10;
}
/**
* @return This returns the suit of the card object from Private suit
*/
char Card::getSuit() {
return suit;
}
/**
* This prints the card. Try to change from int rank to char rank.
*/
void Card::showCard() {
if (rank == 1)
cout << 'A' << getSuit() << " ";
else if (rank == 11)
cout << 'J' << getSuit() << " ";
else if (rank == 12)
cout << 'Q' << getSuit() << " ";
else if (rank == 13)
cout << 'K' << getSuit() << " ";
else if (rank > 1 && rank < 11)
cout << getValue() << getSuit() << " ";
}