Please do this question, and do not use handwriting. Just type it, and that afte
ID: 3787814 • Letter: P
Question
Please do this question, and do not use handwriting. Just type it, and that after you test the code.
1.Draw a class inheritance diagram for the following set of classes:
* Class Goat extends Object and adds an instance variable tail and methods milk() and jump().
* Class Pig extends Object and adds an instance variable nose and methods eat(food) and wallow().
* Class Horse extends Object and adds instance variables height and color, and methods run() and jump().
*Class Racer extends Horse and adds a method race().
*Class Equestrian extends Horse and adds instance variable weight and is-Trained, and methods trot() and isTrained().
Please do this question, and do not use handwriting. Just type it, and that after you test the code.
Use the Java language to do this code
Explanation / Answer
Inheritance diagram for the given set of classes :-
Class Goat extends Object
{
int tail;
void milk() {}
void jump() {}
}
Class Pig extends Object
{
int nose;
void eat(food) {}
void wallow() {}
}
Class Horse extends Object
{
float height;
string color;
void run() {}
void jump() {}
}
Class Racer extends Horse
{
void race() {}
}
Class Equestrian extends Horse
{
float weight;
boolean is-Trained;
void trot() {}
void IsTrained() {}
}