-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCards.java
74 lines (49 loc) · 1.37 KB
/
Cards.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package csci201.unca.edu;
import java.util.Random;
public class Cards {
int faceValue;
int suit;
Random random = new Random();
public Cards() {
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;
}
public static void main(String[] args) {
final Cards card1 = new Cards();
final Cards card2 = new Cards();
final Cards card3 = new Cards();
final Cards card4 = new Cards();
final Cards card5 = new Cards();
System.out.println(card1.displayCard());
System.out.println(card2.displayCard());
System.out.println(card3.displayCard());
System.out.println(card4.displayCard());
System.out.println(card5.displayCard());
}
}