Repository navigation
Expand file tree
/
Copy pathQuiz05.java
More file actions
53 lines (41 loc) · 1.53 KB
/
Copy pathQuiz05.java
File metadata and controls
53 lines (41 loc) · 1.53 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
import java.util.Scanner;
public class Quiz05 {
public static void main(String[] args){
MyDeck myDeck = new MyDeck();
boolean exit = false;
do{
int input = - 1;
input = retrieveMenuChoice();
while(input < 1 || input > 3){
System.out.println("Invalid menu option.\n");
input = retrieveMenuChoice();
}
switch(input){
case 1:
MyCard[] cards = myDeck.getMyCards();
for(int i = 0; i < cards.length; i ++){
System.out.print(cards[i].toString() + ' ');
}
System.out.print("\n\n");
break;
case 2:
myDeck.shuffleDeck();
System.out.println();
break;
case 3:
exit = true;
break;
}
}while(!exit);
}
public static int retrieveMenuChoice(){
Scanner scanner = new Scanner(System.in);
int input = -1;
System.out.println("1. Display the deck");
System.out.println("2. Shuffle the cards");
System.out.println("3. Quit");
System.out.print("(Choose a menu 1, 2, or 3): ");
input = scanner.nextInt();
return input;
}
}