formatting
This commit is contained in:
parent
ba2fb856fa
commit
2189ba86c4
4 changed files with 66 additions and 63 deletions
|
@ -12,22 +12,24 @@ public class EventList{
|
|||
|
||||
public void InsertEvent(int type, double TimeOfEvent) {
|
||||
Event dummy, predummy;
|
||||
predummy = this.list;
|
||||
dummy = this.list.next;
|
||||
|
||||
Event newEvent = new Event();
|
||||
newEvent.eventType = type;
|
||||
newEvent.eventTime = TimeOfEvent;
|
||||
predummy = list;
|
||||
dummy = list.next;
|
||||
while ((dummy.eventTime < newEvent.eventTime) & (dummy != last)){
|
||||
|
||||
while ((dummy.eventTime < newEvent.eventTime) && (dummy != last)) {
|
||||
predummy = dummy;
|
||||
dummy = dummy.next;
|
||||
}
|
||||
|
||||
predummy.next = newEvent;
|
||||
newEvent.next = dummy;
|
||||
}
|
||||
|
||||
public Event FetchEvent() {
|
||||
Event dummy;
|
||||
dummy = list.next;
|
||||
Event dummy = list.next;
|
||||
list.next = dummy.next;
|
||||
dummy.next = null;
|
||||
return dummy;
|
||||
|
|
|
@ -7,15 +7,17 @@ public class MainSimulation extends GlobalSimulation{
|
|||
public static void main(String[] args) throws IOException {
|
||||
Event actEvent;
|
||||
EventList myEventList = new EventList();
|
||||
|
||||
State actState = new State(myEventList);
|
||||
|
||||
myEventList.InsertEvent(ARRIVAL, 0);
|
||||
myEventList.InsertEvent(MEASURE, 5);
|
||||
while (time < 50000){
|
||||
while (MainSimulation.time < 50000) {
|
||||
actEvent = myEventList.FetchEvent();
|
||||
time = actEvent.eventTime;
|
||||
MainSimulation.time = actEvent.eventTime;
|
||||
actState.TreatEvent(actEvent);
|
||||
}
|
||||
System.out.println("Mean number of customers: " + 1.0*actState.accumulated/actState.noMeasurements);
|
||||
System.out.println("Mean number of customers: " + (double) actState.accumulated / actState.noMeasurements);
|
||||
System.out.println("Number of measurements done: " + actState.noMeasurements);
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ class State extends GlobalSimulation{
|
|||
|
||||
private EventList myEventList;
|
||||
|
||||
Random slump = new Random();
|
||||
static Random slump = new Random();
|
||||
|
||||
State(EventList x) {
|
||||
myEventList = x;
|
||||
|
@ -18,7 +18,6 @@ class State extends GlobalSimulation{
|
|||
myEventList.InsertEvent(event, timeOfEvent);
|
||||
}
|
||||
|
||||
|
||||
public void TreatEvent(Event x) {
|
||||
switch (x.eventType) {
|
||||
case ARRIVAL:
|
||||
|
|
Loading…
Reference in a new issue