Lab 2 Comp 249 Exploring Inheritance solution

$24.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (8 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