Last active
August 29, 2015 14:23
-
-
Save ocus/8d2c99b35c1168b57977 to your computer and use it in GitHub Desktop.
Revisions
-
ocus revised this gist
Jun 17, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ # The light show ! You are given the task to create the Java classes corresponding to light bulbs (of different characteristics) that can be individually plugged-in on one of the 4 sockets of a control panel allowing the light on or off at will. The produced code must allow executing the "script" as follows: -
ocus created this gist
Jun 17, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ # The light show ! You are given the task to create the Java classes corresponding to light bulbs (of different characteristics) that can be individually plugged-in on one of the 4 sockets of a control panel allowing the light or off at will. The produced code must allow executing the "script" as follows: static public void main(String[] args) { // Technicians are working hard to mount this... LightBulb a1 = new LightBulb("yellow"); LightBulb a3 = new LightBulb("red"); ControlPanel pdc = new ControlPanel(); pdc.display(); pdc.plugInLightBulb(a1, 1); pdc.plugInLightBulb(a3, 3); pdc.display(); // The mad lighting designer starts his show ! for (int i = 0; i < 10; i++) { System.out.println("Loop: " + i); pdc.display(); pdc.turnOnLightBulb(1); pdc.turnOnLightBulb(2); pdc.display(); pdc.turnOffLightBulb(1); pdc.turnOffLightBulb(2); } // The show was crazy ! } We will make sure that the light bulbs *burn-out after they were lit 7 times*. ## Tasks - Write the code for the classes `LightBulb` and `ControlPanel` in Java. - Write a class `EternalLightBulb` for light bulbs that never burn-out. Use this new light bulb type with the panel. ***You cannot modify the `ControlPanel` class***. - Identify and explain the conception/coding errors induced by the fact of not having thought of all kinds of bulbs from the start.