Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Main Page
Related Pages
Topics
Namespaces
Data Structures
Files
File List
Globals
EXTERNAL_HEADERS
RSL
examples
include
teller.h
Go to the documentation of this file.
1
30
#ifndef TELLER_H_INCLUDED
31
#define TELLER_H_INCLUDED
32
33
inline
int
lcg_rand
(
int
n
);
34
35
class
Customer
36
{
37
public
:
38
39
int
arrivalTime
;
40
int
processTime
;
41
42
Customer
(
int
at = 0)
43
:
arrivalTime
(at),
44
processTime
(2 +
lcg_rand
(6)) {}
45
46
bool
done
() {
// are we done with our transaction?
47
return
--
processTime
< 0;
48
}
49
50
bool
operator<
(
const
Customer
&
c
)
const
{
// order by arrival time
51
return
arrivalTime
<
c
.arrivalTime;
52
}
53
};
54
55
56
class
Teller
57
{
58
public
:
59
Teller
(): free (
true
) { }
60
61
bool
isFree
() {
// are we free to service new customer?
62
if
(free)
63
return
true
;
64
if
(customer.
done
())
65
free =
true
;
66
return
free;
67
}
68
69
void
addCustomer
(
const
Customer
&
c
) {
// start serving new customer
70
customer =
c
;
71
free =
false
;
72
}
73
74
private
:
75
76
bool
free;
77
Customer
customer;
78
};
79
80
#endif
// TELLER_H_INCLUDED
c
#define c
Definition
17.names.cpp:111
n
#define n
Definition
17.names.cpp:130
Customer
Definition
teller.h:36
Customer::Customer
Customer(int at=0)
Definition
teller.h:42
Customer::operator<
bool operator<(const Customer &c) const
Definition
teller.h:50
Customer::processTime
int processTime
Definition
teller.h:40
Customer::done
bool done()
Definition
teller.h:46
Customer::arrivalTime
int arrivalTime
Definition
teller.h:39
Teller
Definition
teller.h:57
Teller::addCustomer
void addCustomer(const Customer &c)
Definition
teller.h:69
Teller::Teller
Teller()
Definition
teller.h:59
Teller::isFree
bool isFree()
Definition
teller.h:61
true
#define true
Definition
stdbool.h:25
lcg_rand
int lcg_rand(int n)
Definition
teller.cpp:39
Generated by
1.9.8