-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimal.java
More file actions
43 lines (37 loc) · 1.31 KB
/
Animal.java
File metadata and controls
43 lines (37 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
public class Animal {
protected String furColor;
private double height;
private double internalWeight;
public double getHeight() { return height; }
public void setHeight(double height) { this.height = height; }
public Animal() {
this.furColor = null;
this.internalWeight = 0.0;
this.height = 0.0;
}
public Animal(String furColor, double weight, double height) {
this.furColor = furColor;
this.height = height;
this.internalWeight = weight;
}
public String vocalize() {
return "*indeterminate*";
}
public String toString() {
return "Fur Color: " + furColor + " weight: " + internalWeight + " height: " + height;
}
public boolean equals(Object other) {
if (other instanceof Animal animal) {
return this.furColor.equals(animal.furColor)
&& this.internalWeight == animal.internalWeight
&& this.height == animal.height;
}
// if (this.getClass() == other.getClass()) {
// Animal animal = (Animal)other;
// return this.furColor.equals(animal.furColor)
// && this.internalWeight == animal.internalWeight
// && this.height == animal.height;
// }
return false;
}
}