Any feedback on this code would be greatly appreciated! I am just trying to improve so I can move on to bigger projects. Thank you so much!
import java.util.*;
import java.util.Random;
public class RockPaperScissors {
public static void main(String [] args)
{
Random rd = new Random();
Scanner kb = new Scanner(System.in);
System.out.println("Welcome to Rock Paper Scisscors!");
while(true)
{
int rock = 1;
int paper = 2;
int scissors = 3;
int conditions [] = {rock, paper, scissors};
int random = (conditions[new Random().nextInt(conditions.length)]);
System.out.print("Please Enter: \n1 for Rock, \n2 for Paper, \n3 for Scissors: ");
int player1 = kb.nextInt();
if(player1 == rock && random == rock)
{
System.out.print("You have tied, computer rock, please try again\n");
}
else if(player1 == paper && random == paper)
{
System.out.print("You have tied, computer chose paper, please try again");
}
else if(player1 == scissors && random == scissors)
{
System.out.print("You have tied, computer chose scissors, please try again");
}
if(player1 == rock && random == paper)
{
System.out.print("Computer chose paper, computer has won");
break;
}
else if(player1 == paper && random == rock)
{
System.out.print("You win!, computer chose rock");
break;
}
else if(player1 == paper && random == scissors)
{
System.out.print("Computer chose scissors, computer has won");
break;
}
else if(player1 == scissors && random == paper)
{
System.out.print("You win, computer chose paper");
break;
}
else if(player1 == rock && random == scissors)
{
System.out.print("You win!, computer chose scissors");
break;
}
else if(player1 == scissors && random == rock)
{
System.out.print("Computer chose rock, computer has won");
break;
}
if(player1 != rock && player1 != paper && player1 != scissors )
{
System.out.print("Invalid response");
break;
}
}
}
}