Project Overview & UML Design
Part of the Object Oriented Programming section of Coddy's Java journey — lesson 77 of 87.
Challenge
EasyLet's kick off the Library Management System project by building the foundation—the core entity classes that everything else will depend on. This first challenge focuses on creating well-structured Book and User classes that follow the UML design from the lesson.
You'll organize your code across three files:
Book.java: Create theBookclass that represents a library book. Each book should have private fields forisbn(String),title(String),author(String), andisAvailable(boolean, defaulting totrue). Include a constructor that accepts isbn, title, and author. Provide appropriate getter methods for all fields, and a setter forisAvailable. Add agetDetails()method that returns a formatted string:[isbn] title by author.User.java: Create theUserclass representing a library member. Each user should have private fields forid(String) andname(String). Include a constructor that accepts both values, and provide getter methods for each field. Add atoString()method that returns:User[id]: name.Main.java: Bring your classes together to demonstrate they work correctly. You'll receive four inputs: a book's ISBN, title, author, and then a user's ID and name.Create a
Bookwith the first three inputs and aUserwith the last two inputs. Print the book's details usinggetDetails(), then print whether the book is available in the formatAvailable: trueorAvailable: false. Finally, print the user using itstoString()method.
You will receive five inputs in order: ISBN (String), title (String), author (String), user ID (String), and user name (String).
For example, with inputs 978-0-13-468599-1, Effective Java, Joshua Bloch, U001, and Alice Smith, your output would be:
[978-0-13-468599-1] Effective Java by Joshua Bloch
Available: true
User[U001]: Alice SmithThese foundational classes will serve as the building blocks for the entire Library Management System. In upcoming lessons, you'll extend them with borrowing functionality, search capabilities, and more!
Try it yourself
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Read book information
String isbn = scanner.nextLine();
String title = scanner.nextLine();
String author = scanner.nextLine();
// Read user information
String userId = scanner.nextLine();
String userName = scanner.nextLine();
// TODO: Create a Book object with isbn, title, and author
// TODO: Create a User object with userId and userName
// TODO: Print the book's details using getDetails()
// TODO: Print whether the book is available (format: "Available: true" or "Available: false")
// TODO: Print the user using toString()
}
}
All lessons in Object Oriented Programming
1Fundamentals of OOP
External FilesIntroduction to OOPClasses vs ObjectsThe this KeywordMethodsFields (Attributes)Constructor MethodConstructor OverloadingRecap - Simple Calculator4Inheritance
Basic Inheritance (extends)The super KeywordMethod Overriding (@Override)Constructor ChainingThe Object ClassSingle & Multilevel InheritWhy No Multi Class InheritRecap - Employee Hierarchy7Special Methods & Object Class
toString() Methodequals() and hashCode()clone() MethodcompareTo() and ComparableComparator InterfaceRecap - Custom Sorting10Exception Handling in OOP
Exception Class HierarchyCustom ExceptionsChecked vs Unchecked ErrorsTry With Resources PatternRecap - Validated User13Project: Library Management
Project Overview & UML DesignBook and User Classes2Access Modifiers & Encapsulate
Access Levels OverviewGetter and Setter MethodsInformation HidingThe final KeywordRecap - Bank Account Manager5Polymorphism
Method Overloading BasicsMethod Overriding (Run-Time)Upcasting and DowncastingThe instanceof OperatorAbstract Classes and MethodsRecap - Shape Calculator8Advanced OOP Concepts
Composition vs InheritanceAggregation vs CompositionInner Nested & Anonymous ClassEnums and Enum MethodsRecords (Java 16+)Sealed Classes (Java 17+)3Class Props & Static Member
Instance vs Static VariablesStatic MethodsStatic BlocksConstants (static final)Recap - Counter & Utility6Interfaces & Abstract Classes
Introduction to InterfacesImplementing InterfacesMulti Interface ImplemenDefault & Static in InterfaceAbstract Classes vs InterfacesFunctional InterfacesRecap - Payment System