Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ 11. Now, a class Dinosaur for keeping track of your collection of dinosaur fossils is to be implemented. Use the following data elements 1.

c++ image text in transcribed
11. Now, a class Dinosaur for keeping track of your collection of dinosaur fossils is to be implemented. Use the following data elements 1. name: data type string 2. age: data type int (years) 3. weight: data type double (kg) 4. planteater: data type boolean Please provide the following functions including implementations 1. Constructor: Dinosaur(string name, int age, double weight, boolean eatsplants). If an age less than zero is entered, the age of the fossil should be set to 100000 years. If a negative weight has been provided, the weight is to be set to 14000 kg 2. Public function: string getName(); returns name of the dinosaur 3. Public function: double get Weight(): returns weight of the dinosaur 4. Public function: void set Weight (double): set weight; if a weight less than 0.0 is entered, the current weight is to be kept. 5. Public function: boolean eats Meat(): if yes: meat eater, if no: plant eater 6. Public function: int getAge(): returns age of the fossil 7. Public function: void setAge(int newage): set the age of the dinosaur fossil. If a value for age is entered that is smaller than the current one, the current age is to be kept. If an age is entered that exceeds 5 billion (5000000000) years, then the age is to be limited to 5 billion years. This class could be used in a main function as follows: 1 Dinosaur stegodon - Dinosaur("Stegosaurus", 157.2epow (10,6), 4.5. 1000, true); 2 Dinosaur veli - Dinosaur("Velociraptor", 82.5 pow(10,6), 15, false); 3 cout

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

Data Science For Dummies

Authors: Lillian Pierson ,Jake Porway

2nd Edition

1119327636, 978-1119327639

Students also viewed these Databases questions

Question

3. Identify the methods used within each of the three approaches.

Answered: 1 week ago