-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatron.java
More file actions
48 lines (37 loc) · 1.03 KB
/
Patron.java
File metadata and controls
48 lines (37 loc) · 1.03 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
/**
* Patron.java
*/
public class Patron{
private String name;
private String email;
private int idNumber;
private double balance;
public void Patron(String name, String email, int idNumber, double balance) {
this.name = name;
this.email = email;
this.idNumber = idNumber;
this.balance = balance;
}
// The adjustBalance will update the current balance of the patron
public double adjustBalance(double amount) {
this.balance += amount;
return this.balance;
}
// The equals method checks whether two patrons have the same id number
public boolean equals(Object other) {
if (other instanceof Patron) {
if (this.idNumber == idNumber) {
return true;
}
}
else if (other instanceof Integer) {
if (this.idNumber == (Integer) other) {
return true;
}
}
return false;
}
public String toString() {
return String.format("Name: %s, Email: %s, Id: %d, Balance: $%.2f",this.name,this.email,this.idNumber,this.balance);
}
}