Answered step by step
Verified Expert Solution
Question
1 Approved Answer
readme.txt Modify theses classes to implement the Observer pattern so that Light objects can be notified when the Button object is pressed. Follow any instructions
readme.txt
Modify theses classes to implement the Observer pattern so that Light objects can be notified when the Button object is pressed. Follow any instructions present in comments.
Button.pseudo
public class Button { | |
public void press() { | |
} | |
} |
Driver.pseudo
public class Driver { | |
public main(){ | |
// create a button | |
// create a red light | |
// create a green light | |
// create a blue light | |
// have the blue light and the red light listen for the button | |
// press the button. Blue and red light should call turnOn in response | |
// NOTE: your Button class should be generic - do not hard-code these | |
// lights into the Button class. | |
} | |
} |
Light.pseudo
public class Light{ | |
private String color; | |
public Light(String color){ | |
this.color = color; | |
} | |
// light turns on with specified color for 1 second | |
public void turnOn(){ | |
} | |
} |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started