Comp 249 Lab 2 Exploring Inheritance

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (7 votes)

File Animal.java contains a declaration for an Animal class.. Files Dog.java and Cat.java contain declarations for classes that extend Animal.

 

Conditions:

 

Animal class variables

String : name (private)

int : numberOfLegs (private)

boolean : vegetarian (private)

 

Animal class methods

Getter and setter for name, numberOfLegs and vegetarian (all are public)

 

Cat class should have following attributes and methods

 

Cat class variables

String : color (private)

 

Cat class methods

Getter and setter color (all are public)

 

Dog class variables

String : color (private)

String : breed (private)

 

Dog class methods

Getter and setter color and breed (all are public)

 

 

1)         All the three classes should have both default and parameterized constructors (This will cover the concept of super and overloading)

2)         Override at least one parent method (maybe name or numberOfLegs or  vegetarian) (This will cover the concept of overriding )

3)         Understand how we can reuse the parent code in child class