More important: it would be easier for OP to read their own code. I shall try displaying the code with code tags soon. I can see at least one formatting error even without code tags; that should have been sorted out automatically by the IDE.
Brecht Geeraerts wrote:It would also be easier . . . to read . . . your code if you'd use the code tags . . .
I tried the code and that does indeed happen. That gave me a hint as to what is going wrong.
Junilu Lacar wrote:. . .
You can do that, yes, but I think that sort of code is error‑prone because it is too easy to copy the numbers wrongly from an ASCII table. I would prefer char myLetter = 'J';
. . .
Campbell Ritchie wrote:It isn't so bad using 0 1 2. The problem is that the program has no way of matching those numbers with P R S entered from the keyboard.
Junilu Lacar wrote:. . . 0, 1, and 2 are poor representations of the idea of Rock, Paper, and Scissors.
Who was it first mentioned enums? Was it Stephan?
. . . enums.
Junilu Lacar wrote:char literals should be enclosed in single quotes, like so:
Also, line 29 should give you a clue:
This will display something like this:
Tip: char is an integer type in Java so you can do this:
Abdallah Taha wrote:I'am asking how to convert the numbers to a char variable with the value of R or S or P
I think your second thread is simply a continuation of your old question, so I have merged the two into one discussion.
Abdallah Taha wrote:. . . convert the numbers to a char variable . . .
That's a pleasure
Abdallah Taha wrote:Thank you
That is what you haven't done. The whole exercise might be useful for showing you how ifs and else‑ifs work, but it is not at all a good way to implement the game, nor is it object‑oriented programming.
. . . compPickInt will now be a 0,1, or 2. Use an ‘if-else if’ structure to convert the numbers to a char variable with the value of R or S or P . . .