Skip to content

YuriiJavaDev/JavaBasics_Task_245_V0.1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Exclusive Club: The Getter Pattern (JavaBasics_Task_245_V0.1)

📖 Description

Encapsulation is not just about hiding data, but about managing access to it. In this project, we implement Getters—special methods that act as safe bridges to our private fields. We also introduce a Parameterized Constructor, which allows us to set the initial state of the Person object at the moment of birth. This design pattern ensures that once a club member is registered, their data is protected from accidental external modification while remaining accessible for reading.

📋 Requirements Compliance

  • Private Field Protection: Fields remain inaccessible from outside the class.
  • Getter Implementation: Added getMemberName() and getMemberAge() for read access.
  • State Initialization: Used a constructor to populate private fields.
  • Clean API: The Solution class interacts only with public methods, not raw data.

🚀 Architectural Stack

  • Java 8+ (Encapsulation, Getters, Constructor Injection)

🏗️ Implementation Details

  • Person: The Model. Encapsulates state and provides an interface for retrieval.
  • ClubReporter: The View. Formats and prints member details using getters.
  • SolutionApp: The Entry Point. Orchestrates member creation and data display.

📋 Expected result

[CLUB INFO]: Member details retrieved via Getters:
Name: Anna
Age: 30

💻 Code Example

Project Structure:

JavaBasics_Task_245/
├── src/
│   └── com/yurii/pavlenko/
│                  ├── Person.java         (Model with Getters)
│                  ├── ClubReporter.java   (Console Output)
│                  └── SolutionApp.java    (Entry Point)
└── README.md

Code

package com.yurii.pavlenko;

public class SolutionApp {

    public static void main(String[] args) {
        ClubReporter reporter = new ClubReporter();

        Person anna = new Person("Anna", 30);

        reporter.printMemberInfo(anna);
    }
}
package com.yurii.pavlenko;

public class Person {
    private String memberName;
    private int memberAge;

    public Person(String name, int age) {
        this.memberName = name;
        this.memberAge = age;
    }

    public String getMemberName() {
        return memberName;
    }

    public int getMemberAge() {
        return memberAge;
    }
}

⚖️ 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_245_V0.1 Controlled Access: implementing the "Getter" pattern and parameterized constructors to provide secure, read-only access to encapsulated data. 160326_1212

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages