subject

Use Inheritance and Polymorphism concepts to create a class named Animal with three derived classes. Each Animal has different characteristics and act different. Create a class that will show these differences by creating objects of type Animal, Dog, Cat and Bird.

Create a base class named Animal with three derived classes named
Gorilla,
Fish, and
Bird.
Create a derived class named Penguin whose base class is Bird.
Create constructors for each class.
Create destructors for each class.
All classes will have the following private instance fields, including Animal
legs that will initialize to 0
boolean swim that will initialize to false;
All classes will have the following polymorphic methods, including Animal
getLegs( ) – this returns the number of legs the animal has
makeSount( ) – this outputs the type of sound the animal makes
canSwim( ) - this will return true or false
makeSound( ) method will be a virtual function in the Animal class
Create an exception in the getLegs( ) method that makes sure the number of legs are valid
Create a main method to demonstrate the all functions including the following with appropriate output

Animal animal;
animal. makeSound();
Dog dog
dog. makeSound();
cout << dog. getLegs();
Animal badDog = Dog();
badDog. makeSound();
cout << badDog. getLegs();
Animal* goodDog = new Dog();
goodDog->makeSound();
cout << goodDog->getLegs;

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 13:50, juan3937
The instruction ishl (shift left integer) exists in jvm but not in ijvm. it uses the top two values on the stack, replacing the two with a single value, the result. the sec- ond-from-top word of the stack is the operand to be shifted. its content is shifted left by a value between 0 and 31, inclusive, depending on the value of the 5 least signifi- cant bits of the top word on the stack (the other 27 bits of the top word are ignored). zeros are shifted in from the right for as many bits as the shift count. the opcode for ishl is 120 (0x78).a. what is the arithmetic operation equivalent to shifting left with a count of 2? b. extend the microcode to include this instruction as a part of ijv.
Answers: 1
image
Computers and Technology, 23.06.2019 17:00, Need1ng
The more powerful, 60 volt cables and the main power shut-off on an hev are both colored orange.
Answers: 1
image
Computers and Technology, 24.06.2019 14:00, maddi0132
In the microsoft® access® and microsoft excel® programs, the ribbon contains tabs that are divided into with like tools in them. parts groups containers bunches
Answers: 1
image
Computers and Technology, 24.06.2019 19:00, stephanieanaya7
In python a floating-point number must be written using scientific notation?
Answers: 1
You know the right answer?
Use Inheritance and Polymorphism concepts to create a class named Animal with three derived classes....

Questions in other subjects:

Konu
Mathematics, 19.11.2020 01:30
Konu
Social Studies, 19.11.2020 01:30
Konu
English, 19.11.2020 01:30