forked from rick2785/JavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDog2.java
More file actions
34 lines (21 loc) · 523 Bytes
/
Dog2.java
File metadata and controls
34 lines (21 loc) · 523 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
public class Dog2 extends Animal3{
public void digHole(){
System.out.println("Dug a hole");
}
public Dog2(){
super();
setSound("Bark");
// We set the Flys interface polymorphically
// This sets the behavior as a non-flying Animal
flyingType = new CantFly();
}
/* BAD
* You could override the fly method, but we are breaking
* the rule that we need to abstract what is different to
* the subclasses
*
public void fly(){
System.out.println("I can't fly");
}
*/
}