SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser
Chapter:
Object-oriented Design
Exercise:
Exercises
Question:12 | ISBN:9781118771334 | Edition: 6

Question

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( ).

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

Class inheritance Diagram:

 

 

0 0

Discussions

Post the discussion to improve the above solution.