Question: Problem Description Objective This practical tests your knowledge of implementing classes with inheritance in mind. It also requires planned application of logic and code structure.

 Problem Description Objective This practical tests your knowledge of implementing classes

with inheritance in mind. It also requires planned application of logic and

code structure. Testing Hint: it's easier if you test things as a

Problem Description Objective This practical tests your knowledge of implementing classes with inheritance in mind. It also requires planned application of logic and code structure. Testing Hint: it's easier if you test things as a small piece of code, rather than building a giant lump of code that doesn't compile or run correctly. As part of your design, you should also sketch out how you are going to build and test each function in the code. Problem In this practical, you are going to improve your Rock Paper Scissors (RPS) program, allowing for greater flexibility. The rules are the same as before: two players compete by choosing Rock, Paper or Scissors and the winner of the game is determined by comparing the choices of the players. Rock beats Scissors, Scissors beats Paper, Paper beats Rock. This practical builds upon the previous practical. As such, we assume that in your implementation, there exist files named Human.cpp Computer.cpp Referee.cpp You are asked to modify these classes with the names provided in the following individual stages. 1. New computer players: Create the following computer players making use of inheritance. You might use your computer player class from Practical 2 as the base class if there is a common behaviour across all computer player subclasses. (Note: the derived Avalanche class may be identical to your base class.) RandonComputer.cpp: RandonComputer returns a random move. Avalanche.cpp: Avalanche always chooses Rock Bureaucrat.cpp: Bureaucrat always chooses Paper. Toolbox.cpp: Toolbox always chooses Scissors. Crescendo.cpp: Crescendo moves in the following order: Paper, Scissors, Rock. Paper Doll.cpp: Paper doll moves in the following order: Paper, Scissors, Scissors. FistfulloDollars.cpp: FistfulloDollars noves in the following order: Rock, Paper, Paper 2. New referee: Previously, referee only matches one human player against one com- puter player. Here, your referee class should be able to match any two players together. (Hint: If you thought in advance in Practical 2 and implemented a common base class for all players, you may save some efforts in this practical) 3. Tournament: Create a class called Tournament in file Tournament.h and Tournament.cpp. In Tournament.cpp there should be a function that sets eight players against each other. The bracket follows the illustration as follows. The rounds are run as illustrated in the picture below. In every round, the winner is determined after five plays (draws count as plays). That is, in every round, two players play against each other five times. The one who wins more advances. If both win the same number of plays, then the player with a lower index advances. (eg. if Player2 and Player4 reach a tie after 5 plays, then Player2 advances.) Also, players "refresh their memories" between rounds. That is, whenever Crescendo enters a round, it plays paper first. Tournament must provide a public function called run with the following interface: Player.run(array competitors) player player2 player player players player player 7 player The testing main function will create the players and a tournament object and then call the tournament run function with the array of player references. The player at competitor[N] is playerN+1 in the tournament. For example, the player at competitor[O] is player1. run() should play the tournament as described above and return the grand winner. Example: If main creates the following player objects for the tournament: Avalanche Bureaucrat Bureaucrat Toolbox Toolbox Crescendo Crescendo FistfulloDollars The winner should be: Toolbox Problem Description Objective This practical tests your knowledge of implementing classes with inheritance in mind. It also requires planned application of logic and code structure. Testing Hint: it's easier if you test things as a small piece of code, rather than building a giant lump of code that doesn't compile or run correctly. As part of your design, you should also sketch out how you are going to build and test each function in the code. Problem In this practical, you are going to improve your Rock Paper Scissors (RPS) program, allowing for greater flexibility. The rules are the same as before: two players compete by choosing Rock, Paper or Scissors and the winner of the game is determined by comparing the choices of the players. Rock beats Scissors, Scissors beats Paper, Paper beats Rock. This practical builds upon the previous practical. As such, we assume that in your implementation, there exist files named Human.cpp Computer.cpp Referee.cpp You are asked to modify these classes with the names provided in the following individual stages. 1. New computer players: Create the following computer players making use of inheritance. You might use your computer player class from Practical 2 as the base class if there is a common behaviour across all computer player subclasses. (Note: the derived Avalanche class may be identical to your base class.) RandonComputer.cpp: RandonComputer returns a random move. Avalanche.cpp: Avalanche always chooses Rock Bureaucrat.cpp: Bureaucrat always chooses Paper. Toolbox.cpp: Toolbox always chooses Scissors. Crescendo.cpp: Crescendo moves in the following order: Paper, Scissors, Rock. Paper Doll.cpp: Paper doll moves in the following order: Paper, Scissors, Scissors. FistfulloDollars.cpp: FistfulloDollars noves in the following order: Rock, Paper, Paper 2. New referee: Previously, referee only matches one human player against one com- puter player. Here, your referee class should be able to match any two players together. (Hint: If you thought in advance in Practical 2 and implemented a common base class for all players, you may save some efforts in this practical) 3. Tournament: Create a class called Tournament in file Tournament.h and Tournament.cpp. In Tournament.cpp there should be a function that sets eight players against each other. The bracket follows the illustration as follows. The rounds are run as illustrated in the picture below. In every round, the winner is determined after five plays (draws count as plays). That is, in every round, two players play against each other five times. The one who wins more advances. If both win the same number of plays, then the player with a lower index advances. (eg. if Player2 and Player4 reach a tie after 5 plays, then Player2 advances.) Also, players "refresh their memories" between rounds. That is, whenever Crescendo enters a round, it plays paper first. Tournament must provide a public function called run with the following interface: Player.run(array competitors) player player2 player player players player player 7 player The testing main function will create the players and a tournament object and then call the tournament run function with the array of player references. The player at competitor[N] is playerN+1 in the tournament. For example, the player at competitor[O] is player1. run() should play the tournament as described above and return the grand winner. Example: If main creates the following player objects for the tournament: Avalanche Bureaucrat Bureaucrat Toolbox Toolbox Crescendo Crescendo FistfulloDollars The winner should be: Toolbox

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!