cs445, Fall 2016 - HW-3Part (i) - 30%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.
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 (ii) - 30%If you din'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 Lightbuld 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 (iii) - 40%
Did you need to re-build the Lightbulb when you replaced the button? VariaFollow the Assignment Submission instructions in the syllabus to submit your work. Don't forget that we'll also have a look at your code repository, make sure you've shared it with us and that you also include instructions for how to check out your code from the command line and how to build it. Don't forget the check out the syllabus for the test environment of your work and what's needed in terms of automated unit testing.
$Id: hw3.html,v 1.1 2016/08/28 15:20:05 virgil Exp $ |