-
Notifications
You must be signed in to change notification settings - Fork 0
/
Member.java
67 lines (63 loc) · 1.56 KB
/
Member.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
package myProjects.library;
public class Member {
private String iDnumber, name,gender;
private int numberOfBooks;
private AccountStatus status;
private double fine;
public Member(String id,String nm,int bn,double fn){
this(id,nm,"Male",bn,fn);
}
public Member(String id,String nm,String g,int bn,double fn){
iDnumber = id;
name = nm;
gender = g;
numberOfBooks = bn;
fine = fn;
status = (fine == 0.0)? AccountStatus.ACTIVE:AccountStatus.SUSPENDED;
}
public Member(String in, String m){
this(in,m,"Male",0,0.0);
}
public String getIDNumber(){
return iDnumber;
}
public String getName(){
return name;
}
public int getNumberOfBooks(){
return numberOfBooks;
}
public double getFine(){
return fine;
}
public AccountStatus getStatus(){
return status;
}
public boolean isActive(){
return getStatus() == AccountStatus.ACTIVE;
}
public void addFine(double fn){
fine += fn;
status = AccountStatus.SUSPENDED;
}
public void payFines(double amt){
fine = (amt <= fine)?fine - amt:0;
if (fine == 0)
status = AccountStatus.ACTIVE;
}
public void setStatus(AccountStatus st){
status = st;
}
public void addBook(int n){
numberOfBooks += n;
}
public void removeBook(int r){
numberOfBooks -= r;
}
public String toString(){
return iDnumber + "#" + name + "#" + numberOfBooks + "#" + fine;
}
public String myPrint(){
return String.format("ID No: %s%nName: %s%nAccount Status: %s%nN0 of Books Borrowed:_%d%n%n",iDnumber,name,status,numberOfBooks);
}
}