Skip to content

YuriiJavaDev/JavaBasics_Task_235_V0.1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Digital Library: Flexible Book Records (JavaBasics_Task_235_V0.1)

📖 Description

A robust library system must handle books even when their full details are not yet known. This project demonstrates Constructor Overloading in Java. We provide two ways to instantiate a Book object: one that uses default placeholder values ("Без названия", 0) and another that accepts specific data upon creation. This ensures every book object in our system is consistently initialized, avoiding null pointers or uninitialized states.

📋 Requirements Compliance

  • Constructor Overloading: Implemented a default (no-args) constructor and a parameterized constructor.
  • Default State: The no-args constructor assigns "Без названия" and 0 pages.
  • Data Integrity: Used the this keyword to map parameters to instance fields.
  • Service Separation: Delegated data presentation to the BookReporter class.
  • Naming Conventions: Followed PascalCase for classes and camelCase for variables.

🚀 Architectural Stack

  • Java 8+ (Constructor Overloading, Default Values, SRP)

🏗️ Implementation Details

  • Book: The Model. Contains two constructors for flexible initialization.
  • LibraryService: The Logic. Handles book creation.
  • BookReporter: The View. Formats and prints book details.
  • LibraryApp: The Orchestrator. Manages the book registration flow.

📋 Expected result

[LIBRARY]: New arrivals registered:
Book: Untitled, pages: 0
Book: Java for Teapots, pages: 350

💻 Code Example

Project Structure:

JavaBasics_Task_235/
            ├── src/
            │   └── com/
            │       └── yurii/
            │           └── pavlenko/
            │               ├── Book.java
            │               ├── LibraryService.java
            │               ├── BookReporter.java
            │               └── LibraryApp.java
            └── README.md

Code

package com.yurii.pavlenko;

public class LibraryApp {

    public static void main(String[] args) {
        LibraryService librarian = new LibraryService();
        BookReporter reporter = new BookReporter();

        Book placeholderBook = librarian.createUnknownBook();
        Book javaBook = librarian.createDefinedBook("Java for Teapots", 350);

        System.out.println("[LIBRARY]: New arrivals registered:");

        reporter.printBookDetails(placeholderBook);
        reporter.printBookDetails(javaBook);
    }
}
package com.yurii.pavlenko;

public class Book {
    public String bookTitle;
    public int numberOfPages;

    public Book() {
        this.bookTitle = "Untitled";
        this.numberOfPages = 0;
    }

    public Book(String title, int pages) {
        this.bookTitle = title;
        this.numberOfPages = pages;
    }
}

⚖️ 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_235_V0.1 Digital Library: implementing constructor overloading to handle both default (placeholder) and fully-defined book entities. 150326_1300

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages