Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

chalBackground: Mr. Burns doesn't care about almost anything ... but himself and his money. So, when his power plant leaked radioactive gooo that caused several

chalBackground: Mr. Burns doesn't care about almost anything ... but himself and his money. So, when his power plant leaked radioactive gooo that caused several species of wildlife to go extinct, he was only concerned with the public perception as it might effect his income and possible jail time. After the appearance of the three-eyed fish, Blinky, other rumors surfaced around the Springfield Nuclear Power Plant. One of them is high concern over the mutation rate of the rare Springfield molted platypus. With barely more than 50 left in the wild, the word "extinction" has been tossed around. So, to quell the media, Mr. Burns had 30 of them captured, dissected, and analysed to check for signs of mutation. He found that the mutation rate is 2% each month, but when they do mutate, they become sterile and cannot reproduce. With this information, he wants to create one of those newfangled computer simulations that the press loves so much. That's where you come in!

Specifications: In this assignment, you will create a class called platypus (in c++). Below, we will describe what will define a platypus. You will also create a main function in which you will create objects of type platypus to test the functionality of your new user-defined type. Incidentally, this kind of main is called a driver, since it is used solely to test something (new). In that driver, you will create enough objects of your new type(s) in order to adequately test their functions. We leave it up to you to do this properly.

Your platypus class is to contain the following:

Member variables:

o a float for weight o a short for age (months) o a char for name initial o a char for gender o a bool to indicate whether alive (or not) o a bool to indicate whether mutant (or not)

Member functions:

o a default constructor that creates a dead platypus o a constructor that you can pass values to so as to establish its gender, weight, age,and name; it will default to alive and not mutant.

o a print function that will output to the screen the attributes of that platypus in anice, easy to read format.

o an age_me function that returns nothing but increments the object's age. It will also include a 2% chance that the object will become a mutant. Further, the platypus has a chance of becoming dead each time it ages. This chance is ten times the platypus' weight. A 5 pound platypus has a 50% chance of death. A 10 pound platypus (or heavier) has a 100% chance of death.

o a fight function that accepts another platypus object as a parameter. It will have the calling platypus attack the other (passed in) platypus. The survivor is based on a "fight ratio": it is calculated as (calling_platypus_weight/other_platypus_weight) * 50. A random value from 1 to 100 is obtained. If it is less than the fight ratio, the calling platypus survives; otherwise the other platypus survives.

o an eat function that increases the weight of the platypus by a random amount from 0.1% to 5.0% of the platypus' current weight.

o A hatch function that will randomly set up a newborn platypus with alive=true, mutant=false, and age=0. Gender will randomly be 'm' or 'f' with equal probability. Weight will randomly be between 0.1 and 1.0 pounds. Name will be randomly chosen from characters a through z.

Note: Think very carefully about writing the above functions and how they should be used. There are indeed circumstances when some functions should not execute. For example, a dead platypus shouldn't eat anything.

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

Step: 3

blur-text-image

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

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

What is Centrifugation?

Answered: 1 week ago

Question

To find integral of ?a 2 - x 2

Answered: 1 week ago

Question

To find integral of e 3x sin4x

Answered: 1 week ago

Question

To find the integral of 3x/(x - 1)(x - 2)(x - 3)

Answered: 1 week ago

Question

What are Fatty acids?

Answered: 1 week ago