Skip to content

YuriiJavaDev/JavaBasics_Task_228_V0.1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Virtual Showroom: Car Inventory (JavaBasics_Task_228_V0.1)

📖 Description

In a professional automotive system, objects must be self-describing. This project models a Car entity that encapsulates both its specifications (brand and production year) and its presentation logic. By moving the display logic into the Car class itself, we ensure that every vehicle "knows" how to present its details to a potential customer, maintaining high cohesion within the object.

📋 Requirements Compliance

  • Model Definition: Created a Car class with carBrand and productionYear fields.
  • Behavior Encapsulation: Implemented the displayDetails() method inside the Car class.
  • Universal Initialization: Used a service class to instantiate and populate car data.
  • Naming Conventions: Followed PascalCase for classes and camelCase for methods/variables.
  • Clean Architecture: Separated the application entry point from data management.

🚀 Architectural Stack

  • Java 8+ (Object State and Behavior, SRP)

🏗️ Implementation Details

The displayDetails() method is an instance method. It doesn't need parameters because it has direct access to the carBrand and productionYear fields of the specific object it belongs to. This is a fundamental concept of OOP: data and the methods that work with that data stay together.

📋 Expected result

Brand: Toyota, production year: 2023

💻 Code Example

Project Structure:

src/com/yurii/pavlenko/
                ├── Car.java
                ├── CarDataInitializer.java
                ├── CarReporter.java
                └── CarShowroomApp.java

Code

package com.yurii.pavlenko;

public class CarShowroomApp {

    public static void main(String[] args) {
        CarDataInitializer initializer = new CarDataInitializer();
        CarReporter reporter = new CarReporter();

        Car showroomCar = initializer.createCar("Toyota", 2023);

        reporter.printCarDetails(showroomCar);
    }
}
package com.yurii.pavlenko;

public class CarDataInitializer {

    public Car createCar(String brand, int year) {
        Car car = new Car();
        car.carBrand = brand;
        car.productionYear = year;
        return car;
    }
}

⚖️ 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_228_V0.1 Virtual Showroom: implementing a Car class with state (brand, year) and encapsulated behavior (displayDetails) to demonstrate object-oriented interaction. 100326_1308

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages