Мое задание для моего класса CS1 - создать игру, похожую на Rock, Paper, Scissors.Это 1, 2, 3, 4 и 5. Мне нужна помощь, чтобы выяснить, как предложить пользователю ввести правильные данные в случае, если они вводят число, которое не 1-5.И мне также нужна помощь, чтобы вставить «Играть снова?»Loop.Пожалуйста, помогите, я так застрял.Я действительно борюсь.
import java.util.Scanner;
import java.util.Random;
public class Moropinzee {
public static void main(String[] args) {
String personPlay1;
String personPlay2;
String response;
Scanner scan = new Scanner(System.in);
Random generator = new Random();
System.out.println("Hey, Let's Play Moropinzee!\n" + "Please enter a move.\n"
+ "Monkey = 1, Robot = 2, Pirate = 3, Ninja= 4, and Zombies = 5.");
System.out.println("Player 1 plays: ");
personPlay1 = scan.next();
System.out.println("Player 2 plays ");
personPlay2 = scan.next();
if (personPlay1.equals(personPlay2))
System.out.println("It's a tie!");
else if (personPlay1.equals("1"))
if (personPlay2.equals("2"))
System.out.println("Monkey unplugs Robot. Player 1 win!!");
if (personPlay1.equals("2"))
if (personPlay2.equals("1"))
System.out.println("Monkey unplugs Robot. Player 2 win!!");
if (personPlay1.equals("1"))
if (personPlay2.equals("3"))
System.out.println("Pirate skewers Monkey. Player 2 win!!");
if (personPlay1.equals("3"))
if (personPlay2.equals("1"))
System.out.println("Pirate skewers Monkey. Player 1 win!!");
if (personPlay1.equals("1"))
if (personPlay2.equals("4"))
System.out.println("Monkey fools Ninja. Player 1 win!!");
if (personPlay1.equals("4"))
if (personPlay2.equals("1"))
System.out.println("Monkey fools Ninja. Player 2 win!!");
if (personPlay1.equals("1"))
if (personPlay2.equals("5"))
System.out.println("Zombie savages Monkey. Player 2 win!!");
if (personPlay1.equals("5"))
if (personPlay2.equals("1"))
System.out.println("Zombie savages Monkey. Player 1 win!!");
if (personPlay1.equals("2"))
if (personPlay2.equals("3"))
System.out.println("Pirate drowns Robot. Player 2 win!!");
if (personPlay1.equals("3"))
if (personPlay2.equals("2"))
System.out.println("Pirate drowns Robot. Player 1 win!!");
if (personPlay1.equals("2"))
if (personPlay2.equals("4"))
System.out.println("Robot chokes Ninja. Player 1 win!!");
if (personPlay1.equals("4"))
if (personPlay2.equals("2"))
System.out.println("Robot chokes Ninja. Player 2 win!!");
if (personPlay1.equals("2"))
if (personPlay1.equals("5"))
System.out.println("Robot crushes Zombie. Player 1 win!!");
if (personPlay1.equals("5"))
if (personPlay1.equals("2"))
System.out.println("Robot crushes Zombie. Player 2 win!!");
if (personPlay1.equals("3"))
if (personPlay2.equals("4"))
System.out.println("Ninja karate chops Pirate. Player 2 win!!");
if (personPlay1.equals("4"))
if (personPlay2.equals("3"))
System.out.println("Ninja karate chops Pirate. Player 1 win!!");
if (personPlay1.equals("3"))
if (personPlay2.equals("5"))
System.out.println("Zombie eats Pirate. Player 2 win!!");
if (personPlay1.equals("5"))
if (personPlay2.equals("3"))
System.out.println("Zombie eats Pirate. Player 1 win!!");
if (personPlay1.equals("4"))
if (personPlay2.equals("5"))
System.out.println("Ninja decapitates Zombie. Player 1 win!!");
if (personPlay1.equals("5"))
if (personPlay2.equals("4"))
System.out.println("Ninja decapitates Zombie. Player 2 win!!");
else {
}
}
}