-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimulationClass.h
More file actions
69 lines (59 loc) · 2.45 KB
/
SimulationClass.h
File metadata and controls
69 lines (59 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef _SIMULATIONCLASS_H_
#define _SIMULATIONCLASS_H_
#include "SimulationClass.h"
#include "FIFOQueueClass.h"
#include "SortedListClass.h"
#include "EventClass.h"
#include "CustomerClass.h"
class SimulationClass
{
private:
int closeTime; // restaurant close time
int arrivalTime; // used to store arrival time
int departureTime; // used to store departure time
int customerNum; // total costumer number
int customerNumNeedWaiting; // total number of customers who need to wait
int customerNumInline; // number of customers waiting in line
int longestLineNum; // longest line customer number
// Waiting time of the customer who wait for the longest time
int longestCustomerWatingTime;
int totalWaitingTime; // total waiting time for all customer
int min; // uniform distribution min value
int max; // uniform distribution max value
double mean; // normal distribution mean value
double stdDev; // normal distribution standard deviation value
bool queueHasCustomer;
int arrivalTimeInverval; // arrived time interval between two customer
int serviceTime; // serivce time for a customer
int totalServiceTime;
// creat a sortedlist to store event
SortedListClass< EventClass > eventList;
// creat a FIFOqueue to store customer
FIFOQueueClass< CustomerClass > queue;
public:
// constructor, set stop time of the simulation
SimulationClass(int inTime,
int seed,
int inMin,
int inMax,
double inMean,
double inStdDev);
// This function generate first customer to start off the simulation
// The first customer arrival event will be add into event list
void setUpSimulation();
// Handle first customer arrival event and serve first customer, add
// first customer departure event to the event list
void startSimulation();
// This function handle departure event: dequeue next customer from
// FIFOqueue and serve this customer
void handleDepartureEvent();
// This funtion handle arrival event: add arrived customer to the
// FIFOqueue and generate next customer arrival event to the event list
void handleArrivalEvent();
// Determine how long this customer will be served and
// generate departure event of this customer to the event list
void serveCustomer();
// this function show statistics data
void showStatistics();
};
#endif