Difference between revisions of "Rock Paper Scissors"

From CompSciWiki
Jump to: navigation, search
Line 6: Line 6:
 
Rock-Paper-Scissors is a game played by two players with a one in three chance of winning. The outcome of each round will result in the player to either win, lose, or tie. In this example, we're going to make a simulation of the game, Rock-Paper-Scissors, to play against the computer. During the execution of the program, the player may request a summary that prints the current score record. The score record includes the number of wins, loses, and ties, as well as the winning average (in percentage) and the player's highest winning streak.
 
Rock-Paper-Scissors is a game played by two players with a one in three chance of winning. The outcome of each round will result in the player to either win, lose, or tie. In this example, we're going to make a simulation of the game, Rock-Paper-Scissors, to play against the computer. During the execution of the program, the player may request a summary that prints the current score record. The score record includes the number of wins, loses, and ties, as well as the winning average (in percentage) and the player's highest winning streak.
  
|SideSection=
+
|SideSectionTitle=...by the Students
[[Image:OperatingSystemExample.jpg|float|267px]]
+
|SideSection=Whenever you are having trouble planning or solving a problem, writing a program, debugging a program, or just analyzing code, write/draw it out on paper. Step through each line of code so you know what you want the program to do, or what that code is doing. When you refer back to the code in your program, use print statements and test your variables to make sure your getting the same results or the results that you should be getting. When you write or draw each step on paper (ex: arrays), this gives you a visual of what your program is doing. In the case you are fixing errors, you can compare and match your program with your diagrams to pin point where the errors occur.
<BR>
+
Taken from http://www.flickr.com/photos/daniello/565304023/
+
  
An image or By Students section
+
|Solution=
  
|Solution=The solution...
 
  
  

Revision as of 01:44, 8 April 2010

Back to the Program-A-Day homepage

Problem

Rock-Paper-Scissors is a game played by two players with a one in three chance of winning. The outcome of each round will result in the player to either win, lose, or tie. In this example, we're going to make a simulation of the game, Rock-Paper-Scissors, to play against the computer. During the execution of the program, the player may request a summary that prints the current score record. The score record includes the number of wins, loses, and ties, as well as the winning average (in percentage) and the player's highest winning streak.

 

...by the Students

Whenever you are having trouble planning or solving a problem, writing a program, debugging a program, or just analyzing code, write/draw it out on paper. Step through each line of code so you know what you want the program to do, or what that code is doing. When you refer back to the code in your program, use print statements and test your variables to make sure your getting the same results or the results that you should be getting. When you write or draw each step on paper (ex: arrays), this gives you a visual of what your program is doing. In the case you are fixing errors, you can compare and match your program with your diagrams to pin point where the errors occur.

Solution

Code

Solution Code

Back to the Program-A-Day homepage