Skip to content
Snippets Groups Projects
Commit 0213d980 authored by Rudi Buss's avatar Rudi Buss
Browse files

Update Exercise 4 - Rock Paper Scissors.txt

parent 1b1be999
Branches main
No related tags found
No related merge requests found
Create a "Rock, Paper, Scissors " program in which the user can play against the computer. The class "Player" is to contain the following data members: - Player name, e.g. "Player", "Computer". - Selection (0, 1 or 2) - Number Wins - Number of games that ended in a draw When the program starts, the following output appears: [0] Scissors [1] Rock [2] Paper Selection Player: ... The user can then choose which tool he wants to select. The computer is then randomly assigned one of the three choices. Then the following is to be compared: If the player has made the same selection as the computer (overload the == operator), then the data member "Draw" for both players increases by 1 each (overload the prefix operator). If the player has won (overload the > operator), then the data member "Win" increases for the player, otherwise for the computer (overload the postfix operator). The input/output operators are also to be overloaded. Input overloading: The options to select a tool are displayed and the selection is stored with the player Output ÒoverloadedÓ: Number of winnings of the player or the computer will be output. A total of 5 moves is made. Finally, the number of winnings or differences is displayed. The output shows who has won or whether it is a draw (overload the >= operator and check who has more wins).
\ No newline at end of file
Create a "Rock, Paper, Scissors " program in which the user can play against the computer.
The class "Player" is to contain the following data members:
- Player name, e.g. "Player", "Computer".
- Selection (0, 1 or 2)
- Number Wins
- Number of games that ended in a draw
When the program starts, the following output appears:
[0] Scissors
[1] Rock
[2] Paper
Selection Player: ...
The user can then choose which tool he wants to select.
The computer is then randomly assigned one of the three choices.
Then the following is to be compared:
If the player has made the same selection as the computer (overload the == operator),
then the data member "Draw" for both players increases by 1 each (overload the prefix operator).
If the player has won (overload the > operator), then the data member "Win" increases for the player, otherwise for the computer (overload the postfix operator).
The input/output operators are also to be overloaded.
Input overloading: The options to select a tool are displayed and the selection is stored with the player
Output "overloaded": Number of winnings of the player or the computer will be output.
A total of 5 moves is made. Finally, the number of winnings or differences is displayed. The output shows who has won or whether it is a draw (overload the >= operator and check who has more wins).
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment