-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibrary.java
More file actions
71 lines (53 loc) · 1.62 KB
/
Library.java
File metadata and controls
71 lines (53 loc) · 1.62 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import java.util.ArrayList;
public class Library {
private ArrayList<Book> books;
private ArrayList<Customer> customers;
private ArrayList<Membership> memberships;
// Generating constructor, getters and setters.
public Library() {
books = new ArrayList<>();
customers = new ArrayList<>();
memberships = new ArrayList<>();
}
public ArrayList<Book> getBooks() {
return books;
}
public ArrayList<Customer> getCustomers() {
return customers;
}
public ArrayList<Membership> getMemberships() {
return memberships;
}
public void setBooks(ArrayList<Book> books) {
this.books = books;
}
public void setCustomers(ArrayList<Customer> customers) {
this.customers = customers;
}
public void setMemberships(ArrayList<Membership> memberships) {
this.memberships = memberships;
}
// Adding methods
public void addBook(Book book) {
books.add(book);
}
public void addCustomer(Customer customer) {
customers.add(customer);
}
public void addMembership(Membership membership) {
memberships.add(membership);
}
public void displayBooks() {
for (Book book : books) {
System.out.println(book.getTitle());
}
}
public void displayCustomers() {
for (Customer customer : customers) {
System.out.println(
customer.getFirstName() + " " +
customer.getLastName()
);
}
}
}