Skip to content

YuriiJavaDev/JavaBasics_Task_329_V0.1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smart Home System: Device Control Logic (JavaBasics_Task_329_V0.1)

📖 Description

A well-designed smart home system requires a balance between specialized behavior and universal standards. This project implements a Smart Device Framework using an abstract Device class. It demonstrates how to combine abstract methods (for device-specific "turn on" procedures) with concrete methods (for a standardized "turn off" algorithm). By inheriting from this base, the Phone class provides its own unique startup sequence while automatically gaining the standard shutdown functionality provided by the parent class.

📋 Requirements Compliance

  • Hybrid Abstraction: Created an abstract class Device with both abstract and concrete behaviors.
  • Specific Implementation: Defined a unique turnOn() logic within the Phone subclass.
  • Inherited Functionality: Leveraged the base turnOff() implementation to avoid code duplication.
  • Sequential Testing: Verified the device lifecycle (activation followed by deactivation) in the launcher.

🚀 Architectural Stack

  • Java 8+ (Abstract Classes, Inheritance, Method Implementation)

🏗️ Implementation Details

  • Device: The abstract base combining a mandatory startup contract with a universal shutdown method.
  • Phone: A concrete smart device implementing its own startup sequence.
  • SmartHomeLauncherApp: The entry point for simulating device interaction.

📋 Expected result

Phone on.
Device off.

💻 Code Example

Project Structure:

JavaBasics_Task_329/
├── src/
│   └── com/yurii/pavlenko/
│                 ├── app/
│                 │   └── SmartHomeLauncherApp.java
│                 └── device/
│                     ├── gadgets/
│                     │   └── Phone.java
│                     └── Device.java
├── LICENSE
├── TASK.md
├── THEORY.md
└── README.md

Code

package com.yurii.pavlenko.app;

import com.yurii.pavlenko.device.gadgets.Phone;

public class SmartHomeLauncherApp {

    public static void main(String[] args) {

        Phone phone = new Phone();
        phone.turnOn();
        phone.turnOff();
    }
}
package com.yurii.pavlenko.device;

public abstract class Device {

    public abstract void turnOn();

    public void turnOff() {
        System.out.println("Device off.");
    }
}
package com.yurii.pavlenko.device.gadgets;

import com.yurii.pavlenko.device.Device;

public class Phone extends Device {

    @Override
    public void turnOn() {
        System.out.println("Phone on.");
    }
}

⚖️ License

This project is licensed under the MIT License.

Copyright (c) 2026 Yurii Pavlenko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files...

License: MIT

About

This is a tutorial project. JavaBasics_Task_329_V0.1 Smart Home System: demonstrating the combination of abstract methods for unique activation logic and concrete methods for universal shutdown procedures. 150426_1451

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages