forked from code-differently/code-differently-24-q1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Book.java
116 lines (104 loc) · 2.44 KB
/
Book.java
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.codedifferently.lesson9.LibraryManagementSystem;
/** Represents a book in the library. */
public class Book {
private String title;
private String author;
private String isbn;
private int numberOfPages;
private boolean checkedOut;
/**
* Constructs a new Book instance with the given parameters.
*
* @param title The title of the book.
* @param isbn The ISBN of the book.
* @param author The author(s) of the book.
* @param numberOfPages The number of pages in the book.
*/
public Book(String title, String isbn, String author, int numberOfPages) {
this.title = title;
this.isbn = isbn;
this.author = author;
this.numberOfPages = numberOfPages;
this.checkedOut = false; // Initially, the book is not checked out
}
/**
* Gets the author(s) of the book.
*
* @return The author(s) of the book.
*/
public String getAuthor() {
return author;
}
/**
* Sets the author(s) of the book.
*
* @param author The author(s) of the book.
*/
public void setAuthor(String author) {
this.author = author;
}
/**
* Gets the ISBN of the book.
*
* @return The ISBN of the book.
*/
public String getIsbn() {
return isbn;
}
/**
* Sets the ISBN of the book.
*
* @param isbn The ISBN of the book.
*/
public void setIsbn(String isbn) {
this.isbn = isbn;
}
/**
* Gets the number of pages in the book.
*
* @return The number of pages in the book.
*/
public int getNumberOfPages() {
return numberOfPages;
}
/**
* Sets the number of pages in the book.
*
* @param numberOfPages The number of pages in the book.
*/
public void setNumberOfPages(int numberOfPages) {
this.numberOfPages = numberOfPages;
}
/**
* Gets the title of the book.
*
* @return The title of the book.
*/
public String getTitle() {
return title;
}
/**
* Sets the title of the book.
*
* @param title The title of the book.
*/
public void setTitle(String title) {
this.title = title;
}
/**
* Checks if the book is currently checked out.
*
* @return True if the book is checked out, false otherwise.
*/
public boolean isCheckedOut() {
return checkedOut;
}
/**
* Sets the checked out status of the book.
*
* @param checkedOut True if the book is to be checked out, false otherwise.
*/
public void setCheckedOut(boolean checkedOut) {
this.checkedOut = checkedOut;
}
}