-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.java
50 lines (37 loc) · 903 Bytes
/
Card.java
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
package edu.unca.csci201;
import java.util.Random;
public class Card {
int faceValue;
int suit;
Random random = new Random();
public Card() {
faceValue = random.nextInt(13)+1;
suit = random.nextInt(4)+1;
}
public String displayCard() {
String cardReadout = "";
cardReadout += "Suit : "; //Reads the Suit
if( suit == 1) {
cardReadout += "Hearts ";
} else if(suit == 2) {
cardReadout += "Diamonds ";
} else if(suit == 3) {
cardReadout += "Spades ";
} else {
cardReadout += "Clubs ";
}
cardReadout += ", Face value : "; //Reads face value
if(faceValue == 1 ) {
cardReadout += "Ace";
} else if(faceValue == 11) {
cardReadout += "Jack";
} else if(faceValue==12) {
cardReadout += "Queen";
} else if(faceValue==13) {
cardReadout += "King";
} else {
cardReadout += faceValue;
}
return cardReadout;
}
}