-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomer.java
More file actions
74 lines (67 loc) · 1.99 KB
/
Customer.java
File metadata and controls
74 lines (67 loc) · 1.99 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
72
73
74
package cs2030.simulator;
/**
* Customer contains int id, double arrivalTime and CustomerType type. The
* Customer class supports operators that includes: (i) Retrieve id. (ii)
* Retrieve arrivalTime. (iii) Retrieve type.
* Customer contains int id, double arrivalTime, and CustomerType type.
*/
public class Customer {
private final int id;
private final double arrivalTime;
private final CustomerType type;
/**
* Constructs a Normal Customer containing an id, and arrival time.
* @param id customer identifier.
* @param arrivalTime customer arrival time.
*/
public Customer(int id, double arrivalTime) {
this.id = id;
this.arrivalTime = arrivalTime;
this.type = CustomerType.NORMAL;
}
/**
* Constructs Customer containing an id, arrival time, and type.
* @param id customer identifier.
* @param arrivalTime customer arrival time.
* @param type customer type.
*/
public Customer(int id, double arrivalTime, CustomerType type) {
this.id = id;
this.arrivalTime = arrivalTime;
this.type = type;
}
/**
* Retrieve customer identifier.
* @return id.
*/
public int getId() {
return id;
}
/**
* Retrieve customer arrival time.
* @return arrivalTime.
*/
public double getArrivalTime() {
return arrivalTime;
}
/**
* Retrieve customer type (i) NORMAL, or (ii) GREEDY.
* @return type.
*/
public CustomerType getType() {
return type;
}
/**
* Retrieve string representation of customer.
* @return customer identifier, and if customer's type is GREEDY, include
* a "(greedy)".
*/
@Override
public String toString() {
if (type == CustomerType.GREEDY) {
return String.format("%d(greedy)", id);
} else {
return String.format("%d", id);
}
}
}