Skip to content

Commit 2534e08

Browse files
committed
chore:Remove main method for PMD and project style compliance
1 parent b26e3a4 commit 2534e08

File tree

1 file changed

+1
-36
lines changed

1 file changed

+1
-36
lines changed

src/main/java/com/thealgorithms/puzzlesandgames/RockPaperScissors.java

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,6 @@ private RockPaperScissors() {
2323
throw new UnsupportedOperationException("Utility class");
2424
}
2525

26-
public static void main(String[] args) {
27-
Scanner scanner = new Scanner(System.in);
28-
Random random = new Random();
29-
30-
String[] options = {"rock", "paper", "scissors"};
31-
32-
System.out.println("=== Rock Paper Scissors Game ===");
33-
System.out.println("Type 'rock', 'paper', or 'scissors'. Type 'exit' to quit.");
34-
35-
while (true) {
36-
System.out.print("\nYour choice: ");
37-
String userChoice = scanner.nextLine().trim().toLowerCase();
38-
39-
if (userChoice.equals("exit")) {
40-
System.out.println("Thanks for playing! ");
41-
break;
42-
}
43-
44-
// Validate input
45-
if (!userChoice.equals("rock") && !userChoice.equals("paper") && !userChoice.equals("scissors")) {
46-
System.out.println("Invalid choice! Try again.");
47-
continue;
48-
}
49-
50-
// Computer chooses randomly
51-
String computerChoice = options[random.nextInt(3)];
52-
System.out.println("Computer chose: " + computerChoice);
53-
54-
// Determine result
55-
String result = getResult(userChoice, computerChoice);
56-
System.out.println(result);
57-
}
58-
59-
scanner.close();
60-
}
61-
6226
public static String getResult(String userChoice, String computerChoice) {
6327
if (userChoice.equals(computerChoice)) {
6428
return "It's a tie!";
@@ -68,6 +32,7 @@ public static String getResult(String userChoice, String computerChoice) {
6832
return "You lose! :( ";
6933
}
7034
}
35+
7136
public static String getRandomChoice() {
7237
String[] options = {"rock", "paper", "scissors"};
7338
Random random = new Random();

0 commit comments

Comments
 (0)