Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Rock, Paper, Scissors Game with inheritance Rock, Paper, Scissors Game with Inheritance It should have an int field called strength and a char field

C++ Rock, Paper, Scissors Game with inheritance

image text in transcribed

Rock, Paper, Scissors Game with Inheritance It should have an int field called strength and a char field mplement a class called Tool. 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 constructor which wil take in an int that is 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 wil also need a public function bool fight(Too that compares their strengths n the following way Rock's strength is doubled (emporarily) when fighting scissors, but halved (temporarily) when fighting paper. n the same way paper has the advantage against rock and scissors against paper. The strength field shouldnt change in the function, which returns true if the original class wins in strength and false otherwise. You may also include any extra auxiliary functions andor fields in any of these classes. Run the program without changing the main function, and verity that the results are oomect e++ -Nall main.cpp -o test ./test Note I want either a 2 file or 3 fie solution. You need to have a rps.h file, also youTI need a nain.cpp file

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_2

Step: 3

blur-text-image_3

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

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions