-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDog.java
More file actions
65 lines (54 loc) · 1.46 KB
/
Dog.java
File metadata and controls
65 lines (54 loc) · 1.46 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
public class Dog extends Animal{
private String earShape;
private String tailShape;
public Dog(){
super("Mutt","Big",50);
}
public Dog(String type, double weight){
this(type,weight,"Perky","Curled");
}
public Dog(String type, double weight, String earShape, String tailShape) {
super(type, weight < 15 ? "small" : (weight < 35?"Medium":"large"), weight);
this.earShape = earShape;
this.tailShape = tailShape;
}
@Override
public String toString() {
return "Dog{" +
"earShape='" + earShape + '\'' +
", tailShape='" + tailShape + '\'' +
"} " + super.toString();
}
public void makeNoise(){
if (type == "Wolf"){
System.out.println("Ow woooo! ");
}
bark();
System.out.println();
}
@Override
public void move(String speed) {
super.move(speed);
// System.out.println("Dogs walk, run and wag their tails");
if (speed=="slow"){
walk();
wagTail();
}else {
run();
bark();
}
System.out.println();
}
private void bark(){
System.out.println("woof!");
}
private void run(){
System.out.println("Dog Running");
}
private void walk(){
System.out.println("Dog walking");
}
private void wagTail(){
System.out.println("Tail Waging");
}
}