Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Specifications: In this assignment, you will create a class called platypus. Below, we will describe what will define a platypus. You will also create a

Specifications: In this assignment, you will create a class called platypus. 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:

a float for weight

a short for age (months)

a char for name initial

a char for gender

a bool to indicate whether alive (or not)

a bool to indicate whether mutant (or not)

Member functions:

a default constructor that creates a dead platypus

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.

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

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.

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.

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.

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

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions

Question

Did you consider possible audience sensitivities?

Answered: 1 week ago

Question

Enter the network portion of 2 1 2 . 1 6 4 . 4 8 . 1 8 6

Answered: 1 week ago