forked from code-differently/code-differently-24-q1
/
Patron.java
65 lines (57 loc) · 1.33 KB
/
Patron.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
package com.codedifferently.lesson9.LibraryManagementSystem;
import java.util.ArrayList;
import java.util.List;
/** Represents a patron of the library. */
public class Patron {
private String name;
private List<Book> checkedOutBooks;
/**
* Constructs a new Patron instance with the given name.
*
* @param name The name of the patron.
*/
public Patron(String name) {
this.name = name;
this.checkedOutBooks = new ArrayList<>();
}
/**
* Gets the name of the patron.
*
* @return The name of the patron.
*/
public String getName() {
return name;
}
/**
* Sets the name of the patron.
*
* @param name The name of the patron.
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets the list of books checked out by the patron.
*
* @return The list of checked out books.
*/
public List<Book> getCheckedOutBooks() {
return checkedOutBooks;
}
/**
* Adds a book to the list of books checked out by the patron.
*
* @param book The book to be added.
*/
public void addCheckedOutBook(Book book) {
checkedOutBooks.add(book);
}
/**
* Removes a book from the list of books checked out by the patron.
*
* @param book The book to be removed.
*/
public void removeCheckedOutBook(Book book) {
checkedOutBooks.remove(book);
}
}