-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDog.java
More file actions
36 lines (31 loc) · 833 Bytes
/
Dog.java
File metadata and controls
36 lines (31 loc) · 833 Bytes
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
public class Dog extends Animal {
String bark;
public Dog() {
super("White", 50.0, 30.0);
this.bark = "Woof";
}
public Dog(String bark, String furColor, double weight, double height) {
super(furColor, weight, height);
this.bark = bark;
super.furColor = furColor;
this.setHeight(height);
}
@Override
public String vocalize() {
return this.bark;
}
@Override
public String toString() {
String superString = super.toString();
return "Bark! " + superString;
}
@Override
public boolean equals(Object other) {
if (!super.equals(other)) {
return false;
} else if (other instanceof Dog otherDog) {
return bark.equals(otherDog.bark);
}
return false;
}
}