#idk what i did wrong
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
You're comparing numbers to characters.
char P = 'p';
Even though you declared user1 and user2 as int's, you can still use == to compare primitive int and char.
Ideally you want something easier to understand.
String paper = "p";
String player1Move = scanner.nextLine()
if( player1Move.startsWith(paper) && player2Move.startsWith(rock){
player1wins
}
the assignment also told me to say why each user won
sure, six cases like you have
what is this statement tho?
prof havent taught me that one
idk if he will allow us to use that statement
I'm renaming your variables to explain what they are.
user1 is player1Move
P is paper.
oh
They can all be strings
so what do i need to fix here
Well you need to declare the three strings which will match the player input
so i use scnr.nextLine()?
and you might as well push everything to lowercase as well
scnr.nextLine().toLowerCase()
Is the input being entered one at time?
with a carriage return?
im not sure
or are you reading from a file
hmm. do your submissions get automatically graded?
So Scanner.next will pull the next string upto some white space out. So if the input is
p r s p p r p s
then that is four rounds of the game.
You really don't need it as character but whatever. It's his rules.
yeah im kinda confused lol
You can still declare the constant characters you'll check against as char
char paper = 'p', rock = 'r', scissor = 's';
char user1 = scnr.next().toLowerCase().charAt(0);
Then in your if statements....
if(user1 == paper && user2 == rock)
is it right
Yes, mostly. We tend to use a constant variable instead of literals though.
where you previously defined it as
char paper = 'p';
do i leave it like that or change to constant?
final char paper = 'p';
will do
do i need to change if statement?
no
well yes, remove the literals, 'p', 'r', 's' and replace with yoru constant variable names
ahh, get rid of the first set of paper, rock, scissor declarations
Ur a wizard, Harry.
lol
thank you so so much for yourhelp
and ur patience
i rlly aprreacited your help
np.
i hope you have a really good day
sure, you too.