feat: bring to working state

This commit is contained in:
Yadunand Prem 2022-09-08 16:23:26 +08:00
parent b33ff933ec
commit 82920fcbc6
5 changed files with 10 additions and 11 deletions

View File

@ -31,7 +31,9 @@ class ArrivalEvent extends Event {
// if no counters available, check if queue slots avialable in counters
availableCounter = this.shop.findCounterWithQueue();
if (availableCounter != null) {
return new Event[] { new JoinCounterQueueEvent(this.getTime(), this.customer, this.shop, availableCounter) };
return new Event[] {
new JoinCounterQueueEvent(this.getTime(), this.customer, availableCounter)
};
}
// if shop queue isn't empty, join shop queue
if (!this.shop.isQueueFull()) {
@ -43,9 +45,6 @@ class ArrivalEvent extends Event {
@Override
public String toString() {
return String.format("%s: %s arrived %s",
super.toString(),
this.customer,
this.shop.queueString());
return String.format("%s: %s arrived %s", super.toString(), this.customer, this.shop);
}
}

View File

@ -1,12 +1,11 @@
public class JoinCounterQueueEvent extends Event {
private Customer customer;
private Shop shop;
private ServiceCounter counter;
public JoinCounterQueueEvent(double time, Customer customer, Shop shop, ServiceCounter counter) {
public JoinCounterQueueEvent(double time, Customer customer, ServiceCounter counter) {
super(time);
this.customer = customer;
this.shop = shop;
this.counter = counter;
}
@Override

View File

@ -19,6 +19,6 @@ class JoinShopQueueEvent extends Event {
public String toString() {
return String.format("%s: %s joined shop queue %s",
super.toString(),
this.customer, this.shop.queueString());
this.customer, this.shop);
}
}

View File

@ -35,7 +35,7 @@ class ServiceEndEvent extends Event {
return new Event[] {
new DepartureEvent(this.getTime(), this.customer),
new ServiceBeginEvent(this.getTime(), serviceCustomer, this.shop, this.counter),
new JoinCounterQueueEvent(this.getTime(), this.shop.leaveQueue(), this.shop, counter)
new JoinCounterQueueEvent(this.getTime(), this.shop.leaveQueue(), counter)
};
}
return new Event[] {

View File

@ -59,7 +59,8 @@ public class Shop {
return null;
}
public String queueString() {
@Override
public String toString() {
return this.queue.toString();
}