Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 2 - OO Rock Paper Scissors Objective This practical tests your skills in writing classes. It also requires a planned application of logic and

Part 2 - OO Rock Paper Scissors

Objective

This practical tests your skills in writing classes. It also requires a planned application of logic and code structure.

Problem

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.

Your design and implementation needs to adhere to the following interfaces.

Player (abstract class)

char makeMove( ); string getName( );

Referee

Referee( ); // constructor Player * refGame(Player * player1, Player * player2) // returns the reference to the winning player

Your submission should contain

Human.cpp Human.h Computer.cpp Computer.h Player.cpp Player.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 and has the name "Computer"

Human Player

A human player object gets its move from user input. The test system will expect an interface where the prompt: Enter move: is displayed and the move is input on the keyboard (ie each time the human player makes a move it will prompt the user to enter a move and expect the user to type a character among R, P, and S followed by pressing the return/enter key.

The human constructor should take a single string which is the human's name. If this string is not passed as a parameter, the name should be set to "Human".

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 a reference to the winning player. In the case of a tie, the referee will return a nullptr.

The main

The main program will create the referee and players, and then ask the referee to adjudicate a game. The main function may create any number of players/referees and call play as many times as it wants.

Main will then print the name of the winner.

For example, if the human player named Mei plays P the output should be Mei Wins. Another example: if the human plays R, the output should be It's a Tie. If Mei plays S, the output should be Computer Wins. (recall the dump computer player always plays rock).

The main purpose of this practical is for you to practice 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 against our own testing main which will only compile against the approved interfaces.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago