Add all 23 GoF design pattern implementations (2026-06-13)
This commit is contained in:
25
02-structural/bridge/AdvancedRemote.java
Normal file
25
02-structural/bridge/AdvancedRemote.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package bridge;
|
||||
|
||||
/**
|
||||
* Refined Abstraction — extends RemoteControl with extra features.
|
||||
* This is how you vary the "abstraction" side independently of the
|
||||
* "implementation" side. Both TV and Radio work with this remote,
|
||||
* even though they know nothing about it.
|
||||
*/
|
||||
public class AdvancedRemote extends RemoteControl {
|
||||
|
||||
public AdvancedRemote(Device device) {
|
||||
super(device);
|
||||
}
|
||||
|
||||
// Extra feature not in the basic remote
|
||||
public void mute() {
|
||||
System.out.println(" Muting " + device.getName());
|
||||
device.setVolume(0);
|
||||
}
|
||||
|
||||
public void jumpToChannel(int channel) {
|
||||
System.out.println(" Jumping to channel " + channel);
|
||||
device.setChannel(channel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user