-
Notifications
You must be signed in to change notification settings - Fork 0
/
Table.java
42 lines (36 loc) · 1.5 KB
/
Table.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
public class Table {
//Since this is a helper class we will let these variables be public rather than writing get methods for them
public int rArrival, sArrival, guests, seatingDelay, serverDelay, length;
private final int seatingAbandonment = 2; //customers willing to wait up to 2 hours to be seated
//private final serverAbandonmentMultiplier = 1.5;
// ===================================
/**
* Constructor
* @param g = number of guest
* @param a = arrival time
* @param l = length of time the party will stay
*/
public Table(int g, int a, int l){
guests = g;
rArrival = a; //restaurant arrival is the given time
length = l;
}
// ===================================
/**
* Updates the tables' arrival time, seating delay, server delay, length of service
* @param serverMultiplier
* @param time = current time
* @return
*/
public boolean seated(double serverMultiplier, int time){
sArrival = time;
seatingDelay = sArrival-rArrival; //restaurant delay = delay between arrival at restaurant and being seated
if(seatingDelay > seatingAbandonment)
return false;
//server delay = difference between actual length with server delay and original length party would have stayed at restaurant
serverDelay = (int)(length*serverMultiplier)-length;
length += serverDelay; //update length to reflect server delay
return true;
}
// ===================================
}