-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mock Q2c #592
Comments
Just create abstract class for each lights and then create anonymous class to toggle from one light to another |
@Swagston20 Hey, do you mind sharing your code for this? I understand creating the abstract classes, but you lost me at the part to create an anonymous class to toggle. Like this toggle do I implement it in TrafficLight or in the various abstract classes? Thank you! |
Redlight redlight = new Redlight() {
} |
@Swagston20 Thanks for the code, I saw it in another post that you sent, however where do you put this chunk of code into? |
If I'm not wrong, the generated |
Hi, actually I am confused with this question and the concept of anonymous inner class. May I ask what is the purpose of defining a property i.e. in the new RedLight() {Redlight red = this; ...} |
Source
mock paper q2c traffic light q!
Description
anyone thought of a way to prevent cyclic dependencies?
part a implementation Red and Green depends on each other
was thinking of creating a new class NextLight which will determine which colour of light to return but its still cyclic since green -> next -> green/ amber/ red
Screenshots (if any):
Insert Images here if necessary
The text was updated successfully, but these errors were encountered: