Question: c++ Inheritance programming:Rock,paper,Scissors You will implement a class called Tool. It should have an int field called strength and a char field called type. You
c++ Inheritance programming:Rock,paper,Scissors You will implement a class called Tool. It should have an int field called strength and a char field called type. You may make them either private or protected. The Tool class should also contain the function void setStrength(int), which sets the strength for the Tool. Create 3 more classes called Rock, Paper, and Scissors, which inherit from Tool. Each of these classes will need a default constructor that sets the strength to 1 and a non-default constructor which will take in an int used to initialize the strength field. The constructor should also initialize the type field using 'r' for Rock, 'p' for Paper, and 's' for Scissors. These classes will also need a public function bool fight(Tool) that compares their strengths in the following way:
Rock's strength is doubled (temporarily) when fighting scissors, but halved (temporarily) when fighting paper.
In the same way, paper has the advantage against rock, and scissors against paper.
The strength field shouldn't change in the function, which returns true if the original class wins in strength and false otherwise.
Also, you must create 3 more classes MagicRock, MagicPaper, and MagicScissors which would inherit from Rock, Paper and Scissors classes respectively. I keep these classes description and functionalty up to your creativity. They should add some twist to the traditional game played and you should comment your reasoning behind your implementations. This part is critical in displaying your design and innovative skills. You may also include any extra auxiliary functions and/or fields in any of these classes. Run the program in a separate main function that would allow two players to play the game by indicating their choices and print who the winner is on the screen. NEED THE CODE IN C++ ..thankyou
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
