Assignments are due at midnight after the following lecture. This assignment is due on Tuesday, January 29 at 11:59pm.
The companion lecture was Lecture 6: C++ Inheritence.
In the file rps.cpp, 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 constructor which will 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 will also need a public function bool fight(Tool) that compares their strengths in the following way:
You may also include any extra auxiliary functions and/or fields in any of these classes. Run the program without changing the main function, and verify that the results are correct.
$ g++ -Wall rps.cpp -o rps $ ./rps <your test output>
Submit your version of the source files on Stellar.
That's easiest from an Athena cluster, but you can download your files from Athena too. First, compress them with a command like this:
tar zcvf assignment6-athenaid.tar.gz *.cpp
Then you can download them with SCP. WinSCP is a good client for Windows. On Linux and OS X, you can use the scp command:
scp email@example.com:assignment6/assignment6-athenaid.tar.gz .
(Note the period at the end of the scp command!)