Skip to content

YuriiJavaDev/JavaBasics_Task_232_V0.1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Virtual Pets: The Birth of Barsik (JavaBasics_Task_232_V0.1)

📖 Description

The transition from a class (blueprint) to an object (instance) is the core of Java programming. This project demonstrates the "lifecycle" of a virtual pet. We declare a Cat template, allocate memory using the new keyword, and then manually define its unique characteristics: "Barsik", aged 3. This process, known as object instantiation, creates a concrete entity in the JVM's Heap memory.

📋 Requirements Compliance

  • Object Instantiation: Successfully used the new keyword to create a Cat instance.
  • State Assignment: Manually assigned "Barsik" and 3 to the object fields.
  • Data Verification: Implemented a reporting mechanism to confirm the pet's attributes.
  • Architectural Separation: Divided responsibilities into Model, Service, and Reporter layers.
  • Naming Conventions: Followed PascalCase for classes and camelCase for variables.

🚀 Architectural Stack

  • Java 8+ (Object Instantiation, Field Access)

🏗️ Implementation Details

  • Cat: The Model. Stores catName and catAge.
  • PetInitializer: The Service. Handles the "birth" and data assignment.
  • PetReporter: The View. Displays the pet's status.
  • VirtualPetApp: The Orchestrator. Coordinates the creation and verification process.

📋 Expected result

[SYSTEM]: A new pet has been created!
Pet Name: Barsik, Age: 3

💻 Code Example

Project Structure:

JavaBasics_Task_232/
        ├── src/
        │   └── com/
        │       └── yurii/
        │           └── pavlenko/
        │               ├── Cat.java            (Model)
        │               ├── PetInitializer.java (Logic of creation)
        │               ├── PetReporter.java    (Console output)
        │               └── VirtualPetApp.java  (Entry point)
        └── README.md

Code

package com.yurii.pavlenko;

public class VirtualPetApp {

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

        System.out.println("[SYSTEM]: A new pet has been created!");

        Cat myCat = initializer.createBarsik();

        reporter.confirmExistence(myCat);
    }
}
package com.yurii.pavlenko;

public class PetInitializer {

    public Cat createBarsik() {

        Cat barsik = new Cat();

        barsik.catName = "Barsik";
        barsik.catAge = 3;

        return barsik;
    }
}

⚖️ 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_232_V0.1 Virtual Pets: instantiating a specific Cat object, manually assigning state (name and age), and verifying data integrity through console output. 110326_1600

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages