Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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: http://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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91597619
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Question suppose you are comparing two algorithms a and b

Question : Suppose you are comparing two algorithms A and B that run on the same machine. The running time of A is 10n log2 n and the running time of B is 50n (assume these are exact running time). What is the smallest v ...

Can someone help me do this i need trace route of

Can someone help me do this i need trace route of Massachusetts Use trace route to trace the route from your home or work computer to the website of a university or company on another continent. Show the traceroute outpu ...

Question research the options for creating a gui on a sun

Question : Research the options for creating a GUI on a Sun Solaris platform that can be duplicated on a Windows platform. Select a tool for creating a dual platform product and specify how much time would be needed for ...

Calculate the standard gibbs free energy change and the

Calculate the standard Gibbs free energy change and the equilibrium constant for the oxidation of a formate ion to carbon dioxide at pH=7 and room temperature.

In unix programming ordinarily the exec system call follows

In UNIX programming, ordinarily the exec() system call follows the fork() call. Explain what would happen if a programmer were to inadvertently place the call to exec() before the call to fork().

Has a recent drop in airplane passengers resulted in better

Has a recent drop in airplane passengers resulted in better on time performance? Before the recent downturn, one airline bragged that 92% of its flights were on time. A random sample of 165 flights completed this year re ...

Question you need to research the topic and discuss the

Question: You need to research the topic and discuss the topic in at 400 words with references. Then, . reference will not count as a discussion. What would be the impact of predictive modeling on healthcare and medicine ...

Question suppose you want to implement a sudoku game that

Question : Suppose you want to implement a Sudoku game that includes nine rows and nine columns of squares. Which layout would be the best one to use and why? The response must be typed, single spaced, must be in times n ...

Question you recently have been hired as the director of

Question: You recently have been hired as the Director of Systems Administration operations for ViralMedia, a provider of software tools for graphics artists. The company's core product, DigiWorld, runs under Windows and ...

For this problem assume the box contains 5 blue balls 7 red

For this problem, assume the box contains 5 blue balls, 7 red balls, and 6 white balls, and that we choose two balls at random from the box. What is the probability of neither being blue given that neither is red?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As