Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Disco class aims to represent a array of 4 bulbs.
- *
- * @author (Avi Ezerzer)
- * @version (3.25 12/05/2014)
- */
- public class Disco
- {
- //declare all bulbs.
- private LightBulb _bulb1;
- private LightBulb _bulb2;
- private LightBulb _bulb3;
- private LightBulb _bulb4;
- /**
- * construct a disco instance comprised of 4 bulbs.
- */
- public Disco(LightBulb b1, LightBulb b2, LightBulb b3, LightBulb b4)
- {
- _bulb1 = b1;
- _bulb2 = b2;
- _bulb3 = b3;
- _bulb4 = b4;
- }
- /**
- * Returns the first LightBulb
- */
- public LightBulb getFirstBulb()
- {
- return _bulb1;
- }
- /**
- * Returns the first LightBulb
- */
- public LightBulb getSecondBulb()
- {
- return _bulb2;
- }
- /**
- * Returns the first LightBulb
- */
- public LightBulb getThirdBulb()
- {
- return _bulb3;
- }
- /**
- * Returns the first LightBulb
- */
- public LightBulb getFourthBulb()
- {
- return _bulb4;
- }
- //comment by cat walking on keyboard nhjjjjjjjjjjjjmmmmmmmmmmmmmmmmmjhnuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
- /**
- * alters the switch state of the lightbulb.
- * @param num - number of the bulb to be switched to counterstate.
- */
- public void switchBulb(int num)
- {
- if (num == 1)
- _bulb1.switchLight();
- else if (num == 2)
- _bulb2.switchLight();
- else if (num == 3)
- _bulb3.switchLight();
- else if (num == 4)
- _bulb4.switchLight();
- }
- /**
- * Turn all the bulbs on
- */
- public void turnAllOn()
- {
- _bulb1.lightOn();
- _bulb2.lightOn();
- _bulb3.lightOn();
- _bulb4.lightOn();
- }
- /**
- * Turn all the bulbs off
- */
- public void turnAllOff()
- {
- _bulb1.lightOff();
- _bulb2.lightOff();
- _bulb3.lightOff();
- _bulb4.lightOff();
- }
- /**
- * checks if all four bulbs are on
- */
- public boolean areAllOn()
- {
- return (_bulb1.isSwitchedOn() && _bulb2.isSwitchedOn() &&_bulb3.isSwitchedOn() &&_bulb4.isSwitchedOn());
- }
- /**
- * checks if all four bulbs are off
- */
- public boolean areAllOff()
- {
- return (!_bulb1.isSwitchedOn() && !_bulb2.isSwitchedOn() && !_bulb3.isSwitchedOn() && !_bulb4.isSwitchedOn());
- }
- /**
- * checks if all bulbs match in color.
- */
- public boolean allSameColor()
- {
- return (_bulb1.getColor().equals(_bulb2.getColor()) &&
- _bulb1.getColor().equals(_bulb3.getColor()) &&
- _bulb1.getColor().equals(_bulb4.getColor()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement