Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Shark NumberOfTeet: int + + Shark ( ( int , , float ) ) + + Swim ( ) ( ) : void + +
Shark
NumberOfTeet: int
+ Shark(int, float)
+ Swim(): void
+ Display(): void
Assume the Shark class above is also a sub class of the Animal class.
a) Add code to your program to implement the Shark class. The Swim method should display "This
shark is swimming". The Display method should print the value of all the attributes in the Shark
object, including any inherited ones.
b) Add code to your main() in the Driver file to create a new Shark object, then invoke the Eat(), Swim() and Display() methods for that object.
Exercise Three
a) Add default, primary and copy constructors to all four classes in your program and instantiate new objects of each class in such a way that each of the constructors for each class gets called in main().
b) Code mutators and accessors for each attribute (including the inherited ones) in each class, then demonstrate how to use these methods on objects created in main()
Step by Step Solution
★★★★★
3.38 Rating (164 Votes )
There are 3 Steps involved in it
Step: 1
Here is an example implementation of the Shark class and the main function in a driver file class Animal attributes and methods of the Animal class cl...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started