forked from rick2785/JavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntertainmentDevice.java
More file actions
45 lines (25 loc) · 950 Bytes
/
EntertainmentDevice.java
File metadata and controls
45 lines (25 loc) · 950 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
40
41
42
43
44
45
// Implementor
// With the Bridge Design Pattern you create 2 layers of abstraction
// In this example I'll have an abstract class representing
// different types of devices. I also have an abstract class
// that will represent different types of remote controls
// This allows me to use an infinite variety of devices and remotes
abstract class EntertainmentDevice {
public int deviceState;
public int maxSetting;
public int volumeLevel = 0;
public abstract void buttonFivePressed();
public abstract void buttonSixPressed();
public void deviceFeedback() {
if(deviceState > maxSetting || deviceState < 0) { deviceState = 0; }
System.out.println("On Channel " + deviceState);
}
public void buttonSevenPressed() {
volumeLevel++;
System.out.println("Volume at: " + volumeLevel);
}
public void buttonEightPressed() {
volumeLevel--;
System.out.println("Volume at: " + volumeLevel);
}
}