TableLamp Java Project
Budget: $10 – $30 USD
IMPORTANT:
- Complete this project using Gradle or maven project feature in Eclipse and send everything in zip.
- Make automated unit tests for the entire project using the jUnit Feature in eclipse (for everything that can be tested).
- Do everything as described below and in the project.txt file.
- DO NOT use too complicated code, try to keep it simple and write comments for what each method/class will do.
Requirements:
Part 1:
Create a project called TableLamp. The TableLamp has a Button and a Lightbulb.
The Lighbulb responds to on() and off() messages. When turned on the light bulb will print to stdout "Lightbulb on". When turned off the light bulb will print to stdout "Lightbulb off."
In a future homework we'll work with more sophisticated light bulbs, such as dimmable and colored.
The Button knows how to respond to switchOn() and switchOff(). Later in this homework we'll work with a different type of button.
When switched on the Button will print "Button switched to ON" to stdout. When switched off the button will print "Button switched to OFF" to stdout.
In the simplest implementation of a TableLamp the Button will have a Lightbulb.
Write a Main class that creates a Button and then commands it to switch on and off.
Part 2:
If you didn't create the Lightbulb and the Button in separate packages, then now it's time to do it.
We'll want them separate because the we want to be able to change the Button without having to rebuild the Lightbulb and we want to be able to change the Lightbulb without having to re-build the Button.
Decouple the Button and the Lightbulb through Dependency Inversion.
Write a Main class that creates a table lamp and then commands it to switch on and off.
Part 3:
Replace the Button with a PushdownButton, one that switches between on and off every time it's pushed. Hint: this button takes a "PushButton()" message.
NOTE: this the same type of "button" - called a pull chain switch - you've seen in table lamps and such, like the one in the image to the left of this text.
Answer this question please:
Did you need to re-build the Lightbulb when you replaced the button?
- Complete this project using Gradle or maven project feature in Eclipse and send everything in zip.
- Make automated unit tests for the entire project using the jUnit Feature in eclipse (for everything that can be tested).
- Do everything as described below and in the project.txt file.
- DO NOT use too complicated code, try to keep it simple and write comments for what each method/class will do.
Requirements:
Part 1:
Create a project called TableLamp. The TableLamp has a Button and a Lightbulb.
The Lighbulb responds to on() and off() messages. When turned on the light bulb will print to stdout "Lightbulb on". When turned off the light bulb will print to stdout "Lightbulb off."
In a future homework we'll work with more sophisticated light bulbs, such as dimmable and colored.
The Button knows how to respond to switchOn() and switchOff(). Later in this homework we'll work with a different type of button.
When switched on the Button will print "Button switched to ON" to stdout. When switched off the button will print "Button switched to OFF" to stdout.
In the simplest implementation of a TableLamp the Button will have a Lightbulb.
Write a Main class that creates a Button and then commands it to switch on and off.
Part 2:
If you didn't create the Lightbulb and the Button in separate packages, then now it's time to do it.
We'll want them separate because the we want to be able to change the Button without having to rebuild the Lightbulb and we want to be able to change the Lightbulb without having to re-build the Button.
Decouple the Button and the Lightbulb through Dependency Inversion.
Write a Main class that creates a table lamp and then commands it to switch on and off.
Part 3:
Replace the Button with a PushdownButton, one that switches between on and off every time it's pushed. Hint: this button takes a "PushButton()" message.
NOTE: this the same type of "button" - called a pull chain switch - you've seen in table lamps and such, like the one in the image to the left of this text.
Answer this question please:
Did you need to re-build the Lightbulb when you replaced the button?
Related categories:
Business, Accounting, Human Resources & Legal
Software Architecture
Test Automation
Eclipse
JUnit