chore: rename ShopCounter to ServiceCounter
This commit is contained in:
parent
41670fb663
commit
6f4af3ba97
@ -21,7 +21,7 @@ class ArrivalEvent extends Event {
|
||||
|
||||
@Override
|
||||
public Event[] simulate() {
|
||||
ShopCounter availableCounter = this.shop.getAvailableCounter();
|
||||
ServiceCounter availableCounter = this.shop.getAvailableCounter();
|
||||
// check if counters are available. If none, push customer to queue if not full.
|
||||
// If full, customer departs
|
||||
if (availableCounter == null) {
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
class DepartureEvent extends Event {
|
||||
|
||||
private ShopCounter counter;
|
||||
private ServiceCounter counter;
|
||||
private Customer customer;
|
||||
private Shop shop;
|
||||
|
||||
@ -17,7 +17,7 @@ class DepartureEvent extends Event {
|
||||
this.shop = shop;
|
||||
}
|
||||
|
||||
public DepartureEvent(double time, Customer customer, Shop shop, ShopCounter counter) {
|
||||
public DepartureEvent(double time, Customer customer, Shop shop, ServiceCounter counter) {
|
||||
super(time);
|
||||
this.customer = customer;
|
||||
this.shop = shop;
|
||||
@ -36,6 +36,7 @@ class DepartureEvent extends Event {
|
||||
return new Event[] {};
|
||||
}
|
||||
Customer c = this.shop.leaveQueue();
|
||||
// Move this to ServiceEndEvent
|
||||
return new Event[] {
|
||||
new ServiceBeginEvent(this.getTime(), c, this.shop, this.counter),
|
||||
};
|
||||
|
@ -7,11 +7,11 @@
|
||||
*/
|
||||
class ServiceBeginEvent extends Event {
|
||||
|
||||
private ShopCounter counter;
|
||||
private ServiceCounter counter;
|
||||
private Customer customer;
|
||||
private Shop shop;
|
||||
|
||||
public ServiceBeginEvent(double time, Customer customer, Shop shop, ShopCounter counter) {
|
||||
public ServiceBeginEvent(double time, Customer customer, Shop shop, ServiceCounter counter) {
|
||||
super(time);
|
||||
this.customer = customer;
|
||||
this.shop = shop;
|
||||
|
@ -5,7 +5,7 @@
|
||||
* @author Yadunand Prem
|
||||
* @version CS2030S AY22/23 Semester 2
|
||||
*/
|
||||
public class ShopCounter {
|
||||
public class ServiceCounter {
|
||||
private static int lastId;
|
||||
|
||||
private final int id;
|
||||
@ -23,7 +23,7 @@ public class ShopCounter {
|
||||
this.available = true;
|
||||
}
|
||||
|
||||
public ShopCounter() {
|
||||
public ServiceCounter() {
|
||||
this.id = lastId++;
|
||||
this.available = true;
|
||||
}
|
@ -7,11 +7,11 @@
|
||||
*/
|
||||
class ServiceEndEvent extends Event {
|
||||
|
||||
private ShopCounter counter;
|
||||
private ServiceCounter counter;
|
||||
private Customer customer;
|
||||
private Shop shop;
|
||||
|
||||
public ServiceEndEvent(double time, Customer customer, Shop shop, ShopCounter counter) {
|
||||
public ServiceEndEvent(double time, Customer customer, Shop shop, ServiceCounter counter) {
|
||||
super(time);
|
||||
this.customer = customer;
|
||||
this.shop = shop;
|
||||
@ -29,4 +29,4 @@ class ServiceEndEvent extends Event {
|
||||
this.counter.free();
|
||||
return new Event[] { new DepartureEvent(this.getTime(), customer, shop, counter) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,13 @@
|
||||
* @version CS2030S AY22/23 Semester 2
|
||||
*/
|
||||
public class Shop {
|
||||
private ShopCounter[] counters;
|
||||
private ServiceCounter[] counters;
|
||||
private Queue queue;
|
||||
|
||||
public Shop(int numOfCounters, int queueSize) {
|
||||
this.counters = new ShopCounter[numOfCounters];
|
||||
this.counters = new ServiceCounter[numOfCounters];
|
||||
for (int i = 0; i < numOfCounters; i++) {
|
||||
this.counters[i] = new ShopCounter();
|
||||
this.counters[i] = new ServiceCounter();
|
||||
}
|
||||
|
||||
this.queue = new Queue(queueSize);
|
||||
@ -25,7 +25,7 @@ public class Shop {
|
||||
* @return the available counter or null if none found
|
||||
*/
|
||||
|
||||
public ShopCounter getAvailableCounter() {
|
||||
public ServiceCounter getAvailableCounter() {
|
||||
for (int i = 0; i < this.counters.length; i++) {
|
||||
if (this.counters[i].isAvailable()) {
|
||||
return counters[i];
|
||||
|
Loading…
Reference in New Issue
Block a user