Rock-Paper-Scissors

Debugging

Either your program works and you are done, or else you have some problems and you don't know why (which is more likely). We have an instructor who is there to help you find those problems, but there's a little more you can do on your own. When you finish this course you will be in the same situation: either try to find your problems on your own, or get help. Later we will tell you how to get Java questions answered on the internet.

On your own, there is a "See Tom's RPS" button on the right side of the entry panel, which you can click to see my version of this program. It will be different from yours, but you should be able to see enough similarities to be able to pick out the significant differences. I suggest you copy your program and paste it into a separate window, so you can look at the two side by side.

If my program works and yours does not, one or more of those differences might be the reason. You can slowly, one line at a time, change my program into yours, trying it each time. If you have different names for your variables than mine, be sure to change the names of each variable all at once. When it stops working, you have found the problem. If that doesn't work, get somebody else to look at it. If you have a friend who can come look at your screen (or use Zoom) see if explaining it to them helps. If none of those work, call the instructor over, it's our job to make sure you do not stay stuck.

You may have noticed that I converted the other player's input to a number (0 or 1 or 2, same as the computer play, but multiplied by 3) and added them together. That way I can use out-of-range numbers to signify invalid input and stop. More friendly would be to politely complain and let the user decide if they want to quit. Of course they can always click the Stop sign (or just walk away).

When your program works OK, or if you want to take a break and work on something different, just save your program text in a separate file (copy the text and paste it into NotePad or whatever you have for saving text on your computer), then turn the page and start learning Java.
 

<<Previous | ToC | Next >>

[2021 May 27]