CS计算机代考程序代写 Java Review:

Review:
CSE148 Object Oriented Programming Homework Set 07
1. OOP principle 1: Encapsulation
2. OOP principle 2: Inheritance
3. OOP principle 3: Polymorphism
4. Overriding & overloading
5. Polymorphism and typecasting (down-casting, up-casting), dynamic binding.
6. Generic programming
Write a Java program to:
Revise classes defined in Homework 06 (adding a new method equals() to each class, when defining/overriding this method, implement a logic of your choice to compare 2 instances and return a boolean value)
1. Redefine class Animal:
Data fields:
name: String
age: int
weight: double
id: int // unique ID of an animal
// implement a method to generate and assign a unique id to // each animal object.
Methods:
Constructor(s)
All setter/getter methods to get or set a data field/member. getAnimalClass(): String // return ¡°Animal¡± as class name
getSpecies(): String // return ¡°Animal Species¡± as general species name toString(): String // return information of this animal object
equals(o: Object): boolean // override ¡°equals()¡± method defined in Object
2. Define class Dog which is inherited from Animal: Data fields:
hasFur: boolean
Methods:
Constructor(s)
All setter/getter methods to get or set a data field/member.
getAnimalClass (): String // override method defined in Animal. Return ¡°Mammal¡±
SCCC CSE148, Spring 2021

getSpecies(): String hasFur(): boolean toString(): String equals(o: Object): boolean
// override method defined in Animal. Return ¡°Dog¡± // return info if this dog has or not has fur
// return information of dog
3. Define class Cat which is inherited from Animal: Data fields:
coat: int // valid values are: 0: short, 1: medium, 2: long.
Methods:
Constructor(s)
All setter/getter methods to get or set a data field/member.
getAnimalClass (): String // override method defined in Animal. Return ¡°Mammal¡±
// override method defined in Animal. Return ¡°Cat¡± // return text message of coat
// return information of a cat
4. Define class Bird which is inherited from Animal: Data fields:
canFly: boolean
Methods:
Constructor
All setter/getter methods to get or set a data field/member.
getAnimalClass (): String // override method defined in Animal. Return ¡°Bird¡±
SCCC CSE148, Spring 2021
getSpecies(): String getCoat(): String toString(): String equals(o: Object): boolean
getSpecies(): String canFly(): boolean toString(): String equals(o: Object): boolean
// override method defined in Animal. Return ¡°Bird¡± // return info if this dog has or not has fur
// return information of this bird object
5. Design a ¡°Zoo¡± class which is the container of Animal objects of different species. Choose ¡°ArrayList¡± to server as container inside this class. This class should include but not limited to these functions: add, remove, search animals; auxiliary functions which are: to list animals in certain order; to get total number of animals in Zoo; to get total animals of a species; is Zoo empty (no animal in Zoo).
The completed design should include:
(a) A UML which describes the members that are defined in this class. Give a brief description of each member.
(b) Java source file(s) which is the implementation of this class.