Write a program to play a three-round match of “rock, paper, scissors” between a person and a computer. Each player should know his or her name and score (i.e., how many games they won, lost, and tied). After the person makes his or her choice, the computer should make its choice at random. After both choices are made, the program should display who won that round. After all three rounds have been played, print out the final score for each player as well as who won the match. For example, if the person won 2 rounds and the computer won 1 round, the person would win the match. Your program must: 1. Store all information and provide all operations listed in the problem description. 2. Use at least one class (but can use more) - all functions should be written as class methods. 3. Include a main method where you allow someone to play a three-round match of “rock, paper, scissors.” 4. Include comments to document your code. Some hints and reminders: 1. Rock beats scissors, scissors beats paper, and paper beats rock. 2. To allow the computer to make its choice at random you will need to use the random library. For example, consider the function random.randint(a,b) which returns a random integer N such that a ≤ N ≤ b. Could this be useful to determine a random choice for the computer? 3. Inheritance may be useful (but is not mandatory).
Aucun commentaire:
Enregistrer un commentaire