Skip to content

Suriok/SmartHome-Simulation

Repository files navigation

SmartHome Simulation

A Java-based console simulation of a smart home system with event-driven interactions, device state management, user activities, and resource consumption tracking.

This project demonstrates object-oriented design, system modeling, and the practical use of multiple design patterns in a larger simulation-based application.

Overview

SmartHome Simulation models a household environment consisting of floors, rooms, users, and smart devices.
The system simulates interactions between users and devices, tracks energy and utility consumption, generates reports, and processes system events.

The project focuses on:

  • object-oriented design
  • system modeling
  • design patterns
  • event-driven architecture
  • state management
  • reporting and consumption tracking

Key Features

  • Smart home structure with floors, rooms, devices, and users
  • Device interaction based on room context
  • User activity simulation
  • Device state transitions
  • Centralized event handling
  • Consumption tracking for electricity, water, and other resources
  • Generated reports for activity, configuration, and usage
  • Use of multiple design patterns in a single system

Architecture

The application is built around a hierarchical object model:

  • House
    • contains multiple Floors
    • each floor contains multiple Rooms
    • rooms contain Devices
    • users move through rooms and interact with available devices

This structure enables contextual device usage and simulation of real household behavior.

Design Patterns Used

The project demonstrates several design patterns:

  • Singleton – centralized system components such as event management
  • Observer – event listeners subscribe to and react to system events
  • State – devices and users change behavior depending on their current state
  • Visitor – reporting logic traverses the smart home structure
  • Iterator – custom iterators simplify traversal of devices and users
  • Factory – device creation is encapsulated in a dedicated factory
  • Builder – smart home configuration is assembled in a structured way

In addition, the project uses Stream API for filtering and aggregation tasks.

Event System

A central event subsystem is responsible for processing and distributing events across the simulation.

Key components include:

  • EventManager – manages subscribers, dispatches events, and stores event history
  • EventPool – reuses event objects to reduce unnecessary allocations
  • EventSource – interface for components that produce events

This makes the simulation more modular and easier to extend.

Reports

The simulation generates reports related to:

  • smart home configuration
  • user activity
  • device usage
  • resource consumption
  • system events

Reporting is one of the core parts of the project and demonstrates traversal and aggregation over the object model.

Diagrams

Main Class Diagram

Smart Home Class Diagram

Iterator Pattern Diagram

Iterator Pattern Diagram

Event / Stream Diagram

Stream class diagram

Tech Stack

  • Java
  • Gradle
  • Log4j2
  • Object-Oriented Programming
  • Java Stream API

Running the Project

Prerequisites

Make sure you have installed:

  • Java 17 or newer
  • Gradle (optional if using the wrapper)

Build the project

./gradlew clean build

Run the simulation

./gradlew run

About

Java smart home simulation featuring OOP, design patterns, event management, and resource consumption tracking.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages