-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCardTest.java
More file actions
43 lines (36 loc) · 1.09 KB
/
CardTest.java
File metadata and controls
43 lines (36 loc) · 1.09 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
class CardDeck{
String shape;
int number;
void deal(){
System.out.println("==>card:"+this.shape+", "+this.number);
}
}
public class CardTest {
public static void main(String[] args) {
int[] Arr = new int[3];//Make array
int k = Arr.length;//length of Array save the k
CardDeck c1 = new CardDeck();
c1.shape = "diamond";
//1
System.out.println("Number of cards currently remaining : " + k);
System.out.println("Pick a card.");
int n = (int) Math.floor(Math.random() * 9) + 2;
Arr[0] = n;
c1.number = n;
c1.deal();
k--;
//2
System.out.println("Number of cards currently remaining : " + k);
System.out.println("Pick a card.");
n = (int) Math.floor(Math.random() * 9) + 2;
while (n == Arr[0]) {
n = (int) Math.floor(Math.random() * 9) + 2;
}
Arr[1] = n;
c1.number = n;
c1.deal();
k--;
//3
System.out.println("Number of cards currently remaining : " + k);
}
}