-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomer.java
112 lines (100 loc) · 2.32 KB
/
Customer.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import java.io.Serializable;
/**
* <p>
* An Object of Customer represents a single customer with relevant customer
* details such as name, contact number and membership status.
* </p>
* <p>
* Customer class is Serializable to enable writing of Customers to the file.
* The readObject and writeObject methods provide implementation details of
* reading and writing Customer Objects to the file respectively.
* </p>
* <p>
* Customer class is comparable and utilizes the contactNo field as the key to
* compare two customer objects.
* </p>
*
* @author Dhruv
*
*/
public class Customer implements Serializable, Comparable<Customer> {
/**
* A UID to allow serialization of Objects of this Class
*/
private static final long serialVersionUID = 8532030939766867255L;
/**
* The name of the customer who made the reservation
*/
private String name;
/**
* The contact number of the customer, also can be used as a customerID
*/
private long contactNo; // Key value for Customer entries
/**
* Shows whether customer is a member or not
*/
private boolean member;
/**
* Constructs a default Customer Object
*/
public Customer() {
super();
}
/**
* Constructs a Customer Object with the provided name, contact number, and
* membership details
*
* @param name
* @param contactNo
* @param member
*/
public Customer(String name, long contactNo, boolean member) {
this.name = name;
this.contactNo = contactNo;
this.member = member;
}
/**
* Returns the Name of the Customer Object
*
* @return String name
*/
public String getName() {
return name;
}
/**
* Returns the Contact number of the Customer Object
*
* @return long contactNo
*/
public long getContactNo() {
return contactNo;
}
/**
* Returns the membership status of the Customer
*
* @return boolean member
*/
public boolean isMember() {
return member;
}
/**
* Sets the member field of the customer to true
*/
public void makeMember() {
this.member = true;
}
/**
* Implements the compareTo function by using the contact Number of the Customer
* as the key for comparing Customer Objects
*
*/
public int compareTo(Customer c) {
if (this.getContactNo() < c.getContactNo()) {
return -1;
} else if (this.getContactNo() > c.getContactNo()) {
return 1;
} else {
return 0;
}
}
}