Ok so today I tried translating the ever confusing pseudo codes that our books give us and this happened. First of all, queues and lists are built in functions in the c++ library right? I have a bunch of compiler errors that wont go away. Queue undeclared, list undeclared, ifstream undeclare and so on.. can someone please tell me what I am doing wrong?
Code is supposed to be a simulation of a fast food place.
Codes:
ItemType.h
struct ItemType
{
char eventType;
int eventTime;
int transTime;
};
sim.cpp
#include <iostream>
#include <fstream>
#include <queue>
#include <list>
#include "ItemType.h"
void simulate()
{
int wait = 0, count = 0;
Queue bankQueue;
LinkedList eventList;
ifstream theFile("sim.dat");
ItemType newEvent;
theFile >> newEvent.eventTime >> newEvent.transTime;
newEvent.eventType = 'A';
eventList.insert(newEvent);
while(!eventList.isEmpty())
{
eventList.retrieve(0, newEvent);
if (newEvent.evenType == 'A')
{ count++;
processArrival(newEvent, theFile, eventList, bankQueue);
}
else
processDeparture(newEvent, eventList, bankQueue, wait);
}
}
void processArrival(itemType aEvent, ifStream& aFile, LinkedList& eList, Queue& bQ)
{
bool atFront = bQ.isEmpty();
bQ.enqueue(aEvent);
eList.remove(aEvent);
if(atFront)
{
itemType dEvent.eventType = 'D';
dEvent.eventTime = aEvent.eventTime + aEvent.transTime;
dEvent.transTime = 0;
eList.insert(dEvent);
}
itemType ev;
if (aFile >> ev.eventTime)
{ ev.eventType = 'A';
aFile >> ev.transTime;
eList.insert(ev);
}
}
Main
#include "sim.cpp"
using namespace std;
int main()
{
simulate();
cin.get();
return 0;
}