-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
75 lines (71 loc) · 2.71 KB
/
Main.java
File metadata and controls
75 lines (71 loc) · 2.71 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
74
75
//Name - Lakshya Joshi
//PRN - 23070126065
//AIML - A2
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// Menu-driven program for deck operations
Scanner scanner = new Scanner(System.in);
Deck deck = new Deck();
while (true) {
System.out.println("\nCARD DECK MENU");
System.out.println("1. Print Deck");
System.out.println("2. Shuffle Deck");
System.out.println("3. Deal 5 Random Cards");
System.out.println("4. Find a Particular Card");
System.out.println("5. Display Cards of a Suit");
System.out.println("6. Display Cards of a Rank");
System.out.println("7. Pick 2 Random Cards");
System.out.println("8. Distribute Cards to 3 Players");
System.out.println("9. Exit");
System.out.print("Enter your choice: ");
int choice = scanner.nextInt();
scanner.nextLine(); // Consume newline
switch (choice) {
case 1:
deck.printDeck();
break;
case 2:
deck.shuffleDeck();
break;
case 3:
deck.dealCard();
break;
case 4:
System.out.print("Enter Rank: ");
String rank = scanner.nextLine();
System.out.print("Enter Suit: ");
String suit = scanner.nextLine();
boolean found = deck.findCard(rank, suit);
if (found) {
System.out.println("Card is in the deck.");
} else {
System.out.println("Card is not in the deck.");
}
break;
case 5:
System.out.print("Enter Suit: ");
String suitSearch = scanner.nextLine();
deck.sameCard(suitSearch);
break;
case 6:
System.out.print("Enter Rank: ");
String rankSearch = scanner.nextLine();
deck.compareCard(rankSearch);
break;
case 7:
deck.randomCards();
break;
case 8:
deck.cardPlayers();
break;
case 9:
System.out.println("Exiting program.");
scanner.close();
return;
default:
System.out.println("Invalid choice! Please enter a valid option.");
}
}
}
}