Guys, kindly help me.
How can user enter a character?
or
How can I use the Enumerated Type for this?
Thanks:)
import java.util.Scanner;
public class RockPaperScissors {
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
char x,y;
System.out.print("Player 1:");
x=input.nextLine();
System.out.print("Player 2:");
y=input.nextLine();
switch(x)
{
case 'P':
switch (y)
{
case 'R':
System.out.print("Player 1 Wins!");
break;
case 'S':
System.out.println("Player 2 Wins!");
break;
case 'P':
System.out.println("Draw!");
break;
}
}
switch (x)
{
case 'R':
switch(y)
{
case 'S':
System.out.println("Player 1 Wins!");
break;
case 'P':
System.out.println("Player 2 Wins!");
break;
case 'R':
System.out.println("Draw!");
break;
}
}
switch (x)
{
case 'S':
switch (y)
{
case 'P':
System.out.println("Player 1 Wins!");
break;
case 'R':
System.out.println("Player 2 Wins!");
break;
case ('S'):
System.out.println("Draw!");
break;
}
}
}
}