0

Rock, paper, error ( Re-upload)

( Re upload because people couldn’t see all my code) I'm making a game for class but there's an error. Whenever I put in something like "paper rock" it will give me the answer I want: " Rock wins! :D" along with a bunch of other answered I didn't want. Sample input: scissors rock Sample output: "Scissors Wins!" "Rock Wins!" "Paper Wins!" etc. What can I do to make it stop doing that and only print out the RIGHT answer? https://code.sololearn.com/cj8nVyNNM9w7/?ref=app (Here is the code here)

13th Sep 2021, 6:20 PM
Err3c
Err3c - avatar
6 Answers
+ 1
Err3c code doesn't works , can you correct it pls!
13th Sep 2021, 6:25 PM
Abhay
Abhay - avatar
+ 1
The code is now working
13th Sep 2021, 6:45 PM
Err3c
Err3c - avatar
+ 1
I put the numbers in to compare them like 4<5 because i thought it would work. ( It worked in my head so thats why I used the numbers to compare) And about the random generator, that was from my previous times using the code. I never got rid of it-( though i probably should)
13th Sep 2021, 7:13 PM
Err3c
Err3c - avatar
+ 1
Abhay when you input those two together it creates an output. But now as I'm typing this out, I'm realizing, it's not in my code....... (oops, sorry) I guess, it was another error. I'm very sorry for the confusion
13th Sep 2021, 8:29 PM
Err3c
Err3c - avatar
0
Err3c Ty! Can you explain in brief what are those 1 , 2 , 3 , 10,20 values doing there ? Also what the following line is suppose to do ? if (rock==rock) { System.out.println("tie :p"); } And you never used generator . According to you input should be scissors , rock or paper but then what are those integer values doing in the program ?
13th Sep 2021, 6:54 PM
Abhay
Abhay - avatar
0
Err3c how does "rock paper" gives an answer as "Rock wins" ?
13th Sep 2021, 8:07 PM
Abhay
Abhay - avatar