-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibraryItem.java
More file actions
51 lines (45 loc) · 1.39 KB
/
LibraryItem.java
File metadata and controls
51 lines (45 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* Abstract base class for library items, such as books.
* Provides common fields and methods for ID, title, and availability.
*/
public abstract class LibraryItem {
protected String id; // Unique identifier
protected String title; // Item title
protected boolean available; // Availability status
/**
* Constructs a LibraryItem with the given details.
* @param id Item's unique identifier
* @param title Item's title
* @param available Whether the item is available
*/
protected LibraryItem(String id, String title, boolean available) {
this.id = id;
this.title = title;
this.available = available;
}
/**
* Gets the item's ID.
* @return ID
*/
public String getId() { return id; }
/**
* Gets the item's title.
* @return title
*/
public String getTitle() { return title; }
/**
* Checks if the item is available.
* @return true if available
*/
public boolean isAvailable() { return available; }
/**
* Sets the item's availability.
* @param available availability status
*/
public void setAvailable(boolean available) { this.available = available; }
/**
* Gets the item's details in a formatted string.
* @return formatted details
*/
public abstract String getDetails();
}