Skip to content

happi1masia-pixel/Java-Tests

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 100.0%