1.3-Object-Georienteerd-Programmeren

Home automation

Create a system that consists of 3 classes: Lamp, DimmableLamp and PhilipsHUELamp:

Implementation of the classes

Write the above classes, where:

Examples

The first output is generated by:

  1. A regular lamp, switched on.
  2. A dimmable lamp, at 50% brightness which is also turned on.
  3. A Philips HUE lamp with the color “green” (note the RBG value), with 100% brightness, but isn’t turned on.
Regular Lamp 
	Status: ON
Dimmable lamp: 
	Brightness: 50%, Status: ON
Philips HUE lamp: 
	Color: java.awt.Color[r=0,g=255,b=0], Brightness: 100%, Status: OFF

The second output shows the same lamps, but with some adjusted settings:

  1. This lamp has been turned off.
  2. This lamp now has a reduced brightness of 50%.
  3. This lamp has been turned on, it’s brightness reduced to 70% and the color was set to “blue”.
Regular Lamp 
	Status: OFF
Dimmable lamp: 
	Brightness: 10%, Status: ON
Philips HUE lamp: 
	Color: java.awt.Color[r=0,g=0,b=255], Brightness: 70%, Status: ON

Testing

In order to test the application, the code from TestApplication can be used. This file can be downloaded here. Make sure that you copy the file to the appropiate location in your project. Make sure all scenarios pass their tests.