Skip to content

Latest commit

 

History

History
132 lines (75 loc) · 1.78 KB

File metadata and controls

132 lines (75 loc) · 1.78 KB

Java-Tests

You are required to build a Smart Home Device Management System.

The system must support multiple types of devices and allow a home to manage them.

This challenge is designed to test your understanding of:

Encapsulation Inheritance Polymorphism Composition Unit Testing (JUnit) 🚨 Rules Do NOT modify the test file Your solution must compile and pass all tests Follow clean OOP principles No hardcoding to satisfy tests 📁 Project Structure src/

└── main/java/

  └── za/co/wethinkcode/smarthome/
  
       Device.java
       Light.java
       Thermostat.java
       SmartHome.java

src/

└── test/java/

  └── za/co/wethinkcode/smarthome/
  
       SmartHomeTest.java

🧩 Requirements

  1. Device (Encapsulation)

Create a class Device with:

Fields

String name

boolean isOn

Methods

void turnOn()

void turnOff()

String getStatus()

Expected Behavior

Devices are OFF by default

getStatus() returns:

is ON

or

is OFF

  1. Light

Create class Light that extends Device.

Fields

String name

int brightness

Methods

Rules

Default brightness = 0

getStatus() must return:

Light is ON at brightness

  1. Thermostat

Create class Thermostat that extends Device.

Fields

double temperature

Methods

Constructor: Thermostat(String name)

void setTemperature(double temperature)

double getTemperature()

Rules

Default temperature = 20.0

getStatus() must return:

Thermostat is ON at °C

  1. SmartHome (Composition)

Create class SmartHome.

Fields

A collection of Device objects

Methods

void addDevice(Device device)

List getDevices()

String getAllStatuses() Expected Behavior

getAllStatuses() returns all device statuses separated by newline (\n)

No trailing newline