-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMember.java
More file actions
27 lines (22 loc) · 959 Bytes
/
Copy pathMember.java
File metadata and controls
27 lines (22 loc) · 959 Bytes
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
import java.util.ArrayList;
import java.util.List;
public class Member {
private String memberId;
private String name;
private List<Book> borrowedBooks;
private double unpaidFines;
public Member(String memberId, String name) {
this.memberId = memberId;
this.name = name;
this.borrowedBooks = new ArrayList<>();
this.unpaidFines = 0.0;
}
public String getMemberId() { return memberId; }
public String getName() { return name; }
public List<Book> getBorrowedBooks() { return borrowedBooks; }
public double getUnpaidFines() { return unpaidFines; }
public void addFine(double amount) { this.unpaidFines += amount; }
public void payFine(double amount) { this.unpaidFines = Math.max(0, this.unpaidFines - amount); }
public void borrowBook(Book book) { borrowedBooks.add(book); }
public void returnBook(Book book) { borrowedBooks.remove(book); }
}