-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBook.java
More file actions
32 lines (27 loc) · 1.04 KB
/
Copy pathBook.java
File metadata and controls
32 lines (27 loc) · 1.04 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
import java.time.LocalDate;
public class Book {
private String isbn;
private String title;
private String author;
private boolean isAvailable;
private LocalDate dueDate;
public Book(String isbn, String title, String author) {
this.isbn = isbn;
this.title = title;
this.author = author;
this.isAvailable = true;
this.dueDate = null;
}
public String getIsbn() { return isbn; }
public String getTitle() { return title; }
public String getAuthor() { return author; }
public boolean isAvailable() { return isAvailable; }
public LocalDate getDueDate() { return dueDate; }
public void setAvailable(boolean available) { isAvailable = available; }
public void setDueDate(LocalDate dueDate) { this.dueDate = dueDate; }
@Override
public String toString() {
String status = isAvailable ? "AVAILABLE" : "CHECKED OUT (Due: " + dueDate + ")";
return String.format("[%s] %s by %s - %s", isbn, title, author, status);
}
}