feat: add authors

This commit is contained in:
Yadunand Prem
2022-08-31 12:31:30 +08:00
parent 66b20a37b7
commit 638c644326
13 changed files with 73 additions and 44 deletions

View File

@@ -1,4 +1,8 @@
/**
* @author Yadunand Prem
* @version CS2030S AY22/23 Semester 2
*/
class ArrivalEvent extends BaseShopEvent { class ArrivalEvent extends BaseShopEvent {
double serviceTime; double serviceTime;

View File

@@ -4,8 +4,8 @@
* simulation. Your task is to replace this * simulation. Your task is to replace this
* class with new classes, following proper OOP principles. * class with new classes, following proper OOP principles.
* *
* @author Wei Tsang * @author Yadunand Prem
* @version CS2030S AY21/22 Semester 2 * @version CS2030S AY22/23 Semester 2
*/ */
abstract class BaseShopEvent extends Event { abstract class BaseShopEvent extends Event {

View File

@@ -1,3 +1,7 @@
/**
* @author Yadunand Prem
* @version CS2030S AY22/23 Semester 2
*/
public class Customer { public class Customer {
final private int id; final private int id;

View File

@@ -1,4 +1,7 @@
/**
* @author Yadunand Prem
* @version CS2030S AY22/23 Semester 2
*/
class DepartureEvent extends BaseShopEvent { class DepartureEvent extends BaseShopEvent {
public DepartureEvent(double time, Customer customer, Shop shop) { public DepartureEvent(double time, Customer customer, Shop shop) {

View File

@@ -9,8 +9,8 @@
* the Comparable interface so that a PriorityQueue can * the Comparable interface so that a PriorityQueue can
* arrange the events in the order of event time. * arrange the events in the order of event time.
* *
* @author Wei Tsang * @author Yadunand Prem
* @version CS2030S AY21/22 Semester 2 * @version CS2030S AY22/23 Semester 2
*/ */
abstract class Event implements Comparable<Event> { abstract class Event implements Comparable<Event> {
/** The time this event occurs in the simulation. */ /** The time this event occurs in the simulation. */

View File

@@ -3,8 +3,8 @@ import java.util.Scanner;
/** /**
* The main class for CS2030S Lab 1. * The main class for CS2030S Lab 1.
* *
* @author Wei Tsang * @author Yadunand Prem
* @version CS2030S AY21/22 Semester 2 * @version CS2030S AY22/23 Semester 2
*/ */
class Lab1 { class Lab1 {
public static void main(String[] args) { public static void main(String[] args) {

View File

@@ -1,4 +1,7 @@
/**
* @author Yadunand Prem
* @version CS2030S AY22/23 Semester 2
*/
class ServiceBeginEvent extends BaseShopEvent { class ServiceBeginEvent extends BaseShopEvent {
double serviceTime; double serviceTime;
@@ -18,7 +21,7 @@ class ServiceBeginEvent extends BaseShopEvent {
@Override @Override
public Event[] simulate() { public Event[] simulate() {
this.counter.setAvailable(false); this.counter.occupy();
double endTime = this.getTime() + this.serviceTime; double endTime = this.getTime() + this.serviceTime;
return new Event[] { return new Event[] {
new ServiceEndEvent(endTime, this.customer, this.shop, this.counter) }; new ServiceEndEvent(endTime, this.customer, this.shop, this.counter) };

View File

@@ -1,4 +1,7 @@
/**
* @author Yadunand Prem
* @version CS2030S AY22/23 Semester 2
*/
class ServiceEndEvent extends BaseShopEvent { class ServiceEndEvent extends BaseShopEvent {
ShopCounter counter; ShopCounter counter;
@@ -16,7 +19,7 @@ class ServiceEndEvent extends BaseShopEvent {
@Override @Override
public Event[] simulate() { public Event[] simulate() {
this.counter.setAvailable(true); this.counter.free();
return new Event[] { new DepartureEvent(this.getTime(), customer, shop) }; return new Event[] { new DepartureEvent(this.getTime(), customer, shop) };
} }
} }

View File

@@ -1,3 +1,7 @@
/**
* @author Yadunand Prem
* @version CS2030S AY22/23 Semester 2
*/
public class Shop { public class Shop {
private ShopCounter[] counters; private ShopCounter[] counters;

View File

@@ -1,3 +1,7 @@
/**
* @author Yadunand Prem
* @version CS2030S AY22/23 Semester 2
*/
public class ShopCounter { public class ShopCounter {
final private int id; final private int id;
private boolean available; private boolean available;
@@ -6,8 +10,12 @@ public class ShopCounter {
return available; return available;
} }
public void setAvailable(boolean available) { public void occupy() {
this.available = available; this.available = false;
}
public void free() {
this.available = true;
} }
public ShopCounter(int id) { public ShopCounter(int id) {

View File

@@ -3,8 +3,8 @@ import java.util.Scanner;
/** /**
* This class implements a shop simulation. * This class implements a shop simulation.
* *
* @author Wei Tsang * @author Yadunand Prem
* @version CS2030S AY21/22 Semester 2 * @version CS2030S AY22/23 Semester 2
*/ */
class ShopSimulation extends Simulation { class ShopSimulation extends Simulation {

View File

@@ -4,8 +4,8 @@
* simulation, inherit from this class and implement * simulation, inherit from this class and implement
* the `getInitialEvents` method. * the `getInitialEvents` method.
* *
* @author Wei Tsang * @author Yadunand Prem
* @version CS2030S AY21/22 Semester 2 * @version CS2030S AY22/23 Semester 2
*/ */
abstract class Simulation { abstract class Simulation {
/** /**

View File

@@ -6,8 +6,8 @@ import java.util.PriorityQueue;
* It runs through the events and simulates each one until * It runs through the events and simulates each one until
* the queue is empty. * the queue is empty.
* *
* @author Wei Tsang * @author Yadunand Prem
* @version CS2030S AY21/22 Semester 2 * @version CS2030S AY22/23 Semester 2
*/ */
public class Simulator { public class Simulator {
/** The event queue. */ /** The event queue. */