Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Dinosaurs have several basic characteristics: a species name, height and weight,

ID: 3634602 • Letter: D

Question

Dinosaurs have several basic characteristics: a species name, height and weight, movement speed, and diet. They also have several basic behaviors: eating, moving, and sleeping.

Your assignment is to define and implement a generic Dinosaur class that defines these characteristics and behaviors. The behaviors can be very basic, just printing out a line saying something like "sleeps." Declare all member fields as private, and make sure that you have accessor functions for all of the member fields.

Use the Dinosaur class as a base class and make classes to represent the following:

For each of these classes, come up with at least two additional pieces of information about that specific dinosaur type (eg, for a Tyrannosaurus, you might have the number of teeth the particular Tyrannosaur has). Also, customize at least one of the sleeping/eating/moving behaviors for each class as appropriate. You can make up any details you want if you don't want to bother looking up information about dinosaurs.

Once you have these classes, write a small program that:

Explanation / Answer

Okay so, a class allows you to build an object that contains multiple attributes, such as in your case, you have a base class, which is like a "parent", the dinosaurs that you create such as the Tyrannosaurus Rex, which is considered the "child" of the dinosaur class. for your base class you have such a format in the dinosaur.h header file. if you don't know what a header file is, well its the main file that all the other child classes will derive from. dinosaur.h: #ifndef DINOSAUR_H // do not worry to much about the first two and last lines, just remember they have to be in the main header file like so. #define DINOSAUR_H class Dinosaur: { public: //all publicly modifiable variables go here private: //all variables that can only be modified through a function go here } #endif now the public and private section will come from how you define an object. so for example say i wanna make an object called dinosaur with 2 legs and four eyes, i could say, din1 = Dinosaur(2, 4) now the two variables legs, and eyes are considered public in such case because i can just define them in what we call a constructor. now what if i wanted to make it so that i could only change a value through a preset function? id have to do this: din1 = Dinosaur() in this case the class object is nulled with all the values currently, but now i can say for example: din1.setlegs(2) that will set the number of legs to 2. now how do we build a class derived from the dinosaur class? we create a new header file, and call it whatever the name of the dinosaur will be, such as TyrannosaurusRex.h once again we need add the #ifndef and endif at the top and bottom like before we create the new class just like the old class, but next to the class name: class Tyrannosaurus_Rex we put: : Dinosaur at the end of the dinosaur name, this will tell the compile u wanna build this class, and derive it from the main class, dinosaur. unfortunatetly it will take a lot of room explaining every single part of the assignment, but if you have any other questions then go ahead and ask :-) hope this helped!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote