Question
In this practical assignment, you are going to implement a simple Rock, Paper, Scissors game in C++. Two players compete and, independently, choose one of
In this practical assignment, you are going to implement a simple Rock, Paper, Scissors game in C++. Two players compete and, independently, choose one of Rock, Paper, or Scissors. They then simultaneously declare their choices. The winner of the game is determined by comparing the choices of the players. Rock beats Scissors, Scissors beats Paper, Paper beats Rock.
A possible interface for my RPS game based on this abstraction.
HumanPlayer
HumanPlayer( ); // constructor char makeMove( );
ComputerPlayer
ComputerPlayer( ); // constructor char makeMove( );
Referee
Referee( ); // constructor char refGame(HumanPlayer player1, ComputerPlayer player2) // returns the outcome for player1: 'W', 'L' or 'T' (Win, Lose, Tie)
You can choose to implement this interface. Alternatively, if your workshop agreed to alternate UMLs approved during your workshop session, you may also implement those interfaces.
Your submission should contain
Human.cpp Human.h Computer.cpp Computer.h Referee.cpp Referee.h
Implementation Details
Computer Player
For this assignment, to make things simple, we assume that the computer player only plays Rock.
Human Player
The human player gets its move from the keyboard (ie each time the human player makes a move it will print the prompt: "Enter move: " and expect the user to enter a single character). A move is a character among R, P, and S.
Gradescope marking is strict on this, ensure your prompt matches this exactly and does not print any other prompts.
Enter move: R
Referee
The referee class will match two players and return their game result. For this practical, your referee class matches the human player and the dumb computer player (who only plays rock). In Practical 3, your referee class will need to match different computer players against each other.
The main
The main program will create the human, referee and computer and then run some number of rock paper scissors games (up to the main function to decide how many).
Main will make a request to the referee object to referee a game. Main will then print the returned result.
For example, if the main decides to play 4 games, and the human player (first player) plays S P R S, the output should be L W T L (L = human loses; W = human wins; T = tie). Another example: if the human plays R R P S, the output should be T T W L. (recall the dump computer player always plays rock).
The main purpose of this practical is for you to practise organizing and writing classes and to recognise how your implementation of your classes can change without having to change the code in main.
In testing, your code will be tested agains our own testing main which will only compile against the approved interfaces.
Marking Scheme
Functionality (3 marks):
- Classes implement the interface - ie they will compile with a main that uses the given or other approved* classes (1 mark) Passing public test cases (1 mark) Passing hidden test cases (1 mark)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started