-
Notifications
You must be signed in to change notification settings - Fork 0
/
washevent.h
76 lines (62 loc) · 1.96 KB
/
washevent.h
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
70
71
72
73
74
75
// <Put your name and date here>
// FILE: washevent.h
// CLASS PROVIDED: washevent
// A washevent has the following features:
// type: the event type, should be one of the following
// { arrival, departure, end_of_simulation }
// time: a real value showing the time of occurence
//
#ifndef WASHEVENT_H
#define WASHEVENT_H
#include <iostream>
using namespace std;
enum events_t { arrival, departure, end_of_simulation };
class washevent{
private:
events_t type;
double time;
unsigned int customer_id;
public:
//constructors
washevent() {}
washevent(events_t type_t, double time_t, unsigned int id)
{
type = type_t;
time = time_t;
customer_id = id;
}
// MODIFICATION MEMBER FUNCTIONS
void set_type(events_t t) { type = t; }
void set_time(double t) { time = t; }
void set_customerid(unsigned int id) { customer_id = id; }
// CONSTANT MEMBER FUNCTIONS
events_t get_type() const { return type; }
double get_time() const { return time; }
unsigned int get_customerid() const { return customer_id; }
void print_info() const
{
switch ( type )
{
case arrival:
cout << "C" << customer_id << " arrives at time " << time << endl;
break;
case departure:
cout << "C" << customer_id << " departs at time " << time << endl;
break;
case end_of_simulation:
cout << "End of simulation at " << time << endl;
break;
default:
cout << "Error: incorrect event type." << endl;
}
}
};
// NON-MEMBER FUNCTION
// Define a function comparing the time of occurence
// purpose: to sort the event list in chronological order
bool comp_time(washevent* first, washevent* second){
if ( first->get_time() < second->get_time() )
return true;
return false;
}
#endif