forked from rick2785/JavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlys.java
More file actions
39 lines (22 loc) · 635 Bytes
/
Flys.java
File metadata and controls
39 lines (22 loc) · 635 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
37
38
39
// The interface is implemented by many other
// subclasses that allow for many types of flying
// without effecting Animal, or Flys.
// Classes that implement new Flys interface
// subclasses can allow other classes to use
// that code eliminating code duplication
// I'm decoupling : encapsulating the concept that varies
public interface Flys {
String fly();
}
// Class used if the Animal can fly
class ItFlys implements Flys{
public String fly() {
return "Flying High";
}
}
//Class used if the Animal can't fly
class CantFly implements Flys{
public String fly() {
return "I can't fly";
}
}