-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cc
66 lines (53 loc) · 1.88 KB
/
main.cc
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
#include "config.h"
#include "MPRNG.h"
#include <iostream>
#include <time.h>
#include "printer.h"
#include "bank.h"
#include "parent.h"
#include "watcardoffice.h"
#include "nameserver.h"
#include "vendingmachine.h"
#include "bottlingplant.h"
#include "student.h"
using namespace std;
MPRNG rand_gen;
void uMain::main(){
string passin;
try {
passin = argv[1];
} catch ( ... ) {
cout << "./soda [config filename]" << endl;
}
//prepare target
//string passin="test.config";
//char* target=new char[passin.size()+1];
//target[passin.size()]=NULL;//null terminate
//copy(passin.begin(),passin.end(),target);
const char* target=passin.c_str();
ConfigParms myparms;
//prepare
processConfigFile(target, myparms);
int seed=time(NULL);
rand_gen.seed(seed);
Printer myprinter(myparms.numStudents,myparms.numVendingMachines,myparms.numCouriers);
Bank mybank(myparms.numStudents);
Parent myparent(myprinter,mybank,myparms.numStudents,myparms.parentalDelay);
WATCardOffice myoffice(myprinter,mybank,myparms.numCouriers);
NameServer mynameserver(myprinter,myparms.numVendingMachines,myparms.numStudents);
BottlingPlant mybottlingplant(myprinter,mynameserver,myparms.numVendingMachines,myparms.maxShippedPerFlavour,myparms.maxStockPerFlavour,myparms.timeBetweenShipments);
VendingMachine* mymachines[myparms.numVendingMachines];
Student* mystudents[myparms.numStudents];
for(unsigned int i=0;i<myparms.numVendingMachines;i++){
mymachines[i]=new VendingMachine(myprinter,mynameserver,i,myparms.sodaCost,myparms.maxStockPerFlavour);
}
for(unsigned int i=0;i<myparms.numStudents;i++){
mystudents[i]=new Student(myprinter,mynameserver,myoffice,i,myparms.maxPurchases);
}
for(unsigned int i=0;i<myparms.numStudents;i++){
delete mystudents[i];
}
for(unsigned int i=0;i<myparms.numVendingMachines;i++){
delete mymachines[i];
}
}