feat: update structure

This commit is contained in:
2024-01-22 14:27:40 +08:00
parent 7836c9185c
commit 3544a28a2e
559 changed files with 120846 additions and 4102 deletions

View File

@@ -0,0 +1,34 @@
/**
* The ServiceBeginEvent is an Event which handles the starting of a service.
* It handles occupying a counter and also generating a serviceEndEvent
*
* @author Yadunand Prem
* @version CS2030S AY22/23 Semester 2
*/
class ServiceBeginEvent extends Event {
private ServiceCounter counter;
private Customer customer;
private Shop shop;
public ServiceBeginEvent(double time, Customer customer, Shop shop, ServiceCounter counter) {
super(time);
this.customer = customer;
this.shop = shop;
this.counter = counter;
}
@Override
public String toString() {
return super.toString()
+ String.format(": %s service begin (by %s)", this.customer, this.counter);
}
@Override
public Event[] simulate() {
this.counter.occupy();
double endTime = this.getTime() + this.customer.getServiceTime();
return new Event[] {
new ServiceEndEvent(endTime, this.customer, this.shop, this.counter) };
}
}