Need a public function bool fight

Assignment Help Basic Computer Science
Reference no: EM13924736

Assignment #3

More OOP - "Is A" Relationship/Inheritance

Grading: For each programming assignment, you are graded by explaining and demoing your code to a TA. You must demo your program BEFORE the next assignment is due, and if you fail to do so, you will automatically lose 50 points! Your job is to convince the TA that your program works correctly, i.e. show your TA how to use/break your program

Problem Statement (Idea from the MIT OpenCourseWare):

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.

You may also include any extra auxiliary functions and/or fields in any of these classes.
In addition, you will create a class called RPSGame, which allows a human to play the rock, paper, scissors game against the computer. Your RPSGame must have two Tool * for the human and computer tool because you don't know the new tool they'll select with each round. The RPSGame should also have three int fields to keep track of the number of human_wins, computer_wins, and ties.

You can choose the strategy for the computer guesses, but it cannot be based on what the human selected for a tool in the current game!!! Example of a novice and veteran computer AI: https://www.nytimes.com/interactive/science/rock-paper-scissors.html?_r=0
After the human selects the tool for the current game, display the computer's tool, a message describing who won, the current stats for the wins and ties, and then ask the user if he/she wants to play again.

Example Play of Game:
Welcome to Rock, Paper, Scissors! Do you want to choose different strengths for the tools? (y-yes, n-no) n
Choose your tool (r-rock, p-paper, s-scissor, e-exit): r
Computer chose scissor.
You win!!!
Human wins: 1
Computer wins: 0
Ties: 0
Choose your tool (r-rock, p-paper, s-scissor, e-exit): r
Computer chose paper.
Computer wins! :-(
Human wins: 1
Computer wins: 1
Ties: 0
Choose your tool (r-rock, p-paper, s-scissor, e-exit): e
Things to consider:

  • You must have the proper constructors, destructors, and assignment operator overload for the Tool, Rock, Paper, Scissor, and RPSGame classes.
  • Your member variables in all classes must be private or protected for encapsulation rules.
  •  You must have your class definitions in a .h file and your implemented classes in .cpp files.
  • You must also have your main function in a play_game.cpp file, separated from the class implementations.

Reference no: EM13924736

Questions Cloud

Using the formula and financial calculator methods : The Horizon Company will invest $60,000 in a temporary project that will generate the following cash inflows for the next three years. Use Appendix B for an approximate answer but calculate your final answer using the formula and financial calculator..
Short memo to the management of cycle city : Write a short memo to the management of Cycle City Inc., explaining a. Over what range of assembly hours is the dual price applicable?
What is the net present value and internal rate of return : Anderson International Limited is evaluating a project in Erewhon. The project will create the following cash flows: Year Cash Flow 0 –$579,000 1 209,000 2 152,000 3 217,000 4 196,000 All cash flows will occur in Erewhon and are expressed in dollars...
Article:- eating christmas in the kalahari : What was the author's plan for rewarding his hosts for putting up with a pushy anthropologist for an entire year? How did the !Kung respond to his gift? Now the crux, WHY did they react this way? Be sure to discuss relative status, egalitarianism,..
Need a public function bool fight : Grading: For each programming assignment, you are graded by explaining and demoing your code to a TA. You must demo your program BEFORE the next assignment is due, and if you fail to do so, you will automatically lose 50 points! Your job is to con..
Each year with the first payment due december : Prepare all the general journal entries related to these bonds for 2013 and 2014.
How does use of the cloud affect the local environment : Write a 2- to 3-page paper explaining how the networking infrastructure and use of the cloud can impact overall network availability and functionality applies to the global environment. How does use of the cloud affect the local environment
How a credit crisis can lead to a full-blown economic crisis : Explain how a credit crisis can lead to a full-blown economic crisis. Explain the similarities between the 1929 Great Crash and the 2008 Credit Crisis. What are the lessons learned from the 2008 Credit Crisis? Please elaborate.
What are the conditions imposed on a debt issues : What are the conditions imposed on a debt issues that are designed to protect bondholders called? collatreal agreements, default provisions, protective covenants or vanilla wrapper

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Use a for loop to iterate through the array and input values

Use a For loop to iterate through the array and input the values.

  Difference between a function prototype and a definition

Explain the difference between a function prototype and a function definition

  Monitoring performance of it acquisition projects

Who is or should be responsible for monitoring the performance of IT acquisition projects and taking action that may result in cancelling the project?

  Comp dq microsoft''s website

This discussion board allows you to work with Word templates available on Microsoft's website. First, download a Word template from Microsoft.com by clicking Office, then Templates, then Word. Replace the placeholders with your own content. Upload..

  What is the position of the first queue element

Suppose that queue is implemented as an array with the special reserved slot, as described in this chapter. Also, suppose that the size of the array implementing queue is 100. If the value of queueFront is 50, what is the position of the first queue ..

  Explain the current business rules for drive-n-drop

Create an ERD for each of the following statements that describe the current business rules for Drive-n-Drop. For each new statement being the business rule, extend the ERD to include the additional business rule in the ERD

  Complete a partially filled out expense report

Complete a partially filled out expense report for a company's sales force and then save it. To view these instructions while you work in Excel, you can print this page of instructions or move back and forth between this page and Excel by clicking..

  Provide a real-life example of a software application

Provide a real-life example of a software application that illustrates the different types of adaptors needed to support sequential composition and a real-life example of a software application that illustrates the different types of adaptors need..

  What is the simplest form of the boolean function

What is the simplest form of the Boolean function y′ . (x + y)?

  Recursive relationship between research methods and data

recursive relationship between research methods and data collection techniques

  Powerpoint are used in the criminal justice system

Question: How do you think Microsoft Office Word and PowerPoint are used in the criminal justice system (CJS). What do you think are the best uses for Microsoft Office Word and PowerPoint in the CJS

  Signal that includes creating lpf

The next step is processing the signal that includes creating LPF, removing silent regions and scaling the signal in the time domain. Can someone help with the matlab code for this part of my project and the next 2 parts which include feature extract..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd