#include #include #include #include #include "item.h" #include "student.h" #include "manager.h" using namespace std; void main() { ifstream initem("items.data"); //items file ifstream instud("students.data"); //students file ifstream incom("commands.data"); //commands file ofstream outdata("output.data"); // output file Manager dude; //the manager string com, info; //for the inputs int spot = -1; //to figure where to put new items and students getline(instud, com); //get from file while(!instud.eof()) //importing students { spot++; while(com != "@@") //end of new student { getline(instud, info); assert(spot >= 0); dude.newStudent(com, info, spot); //adds the student info getline(instud, com); if(com == "@@") { getline(instud, com); break; } } if(dude.studExist(spot) == false) //makes sure that the student was actually added { dude.resetItem(spot); dude.resetStud(spot); spot--; } getline(instud, com); } spot = -1; getline(initem, com); while(!initem.eof()) //importing items { spot++; while(com != "@@") { getline(initem, info); assert(spot >= 0); dude.newItem(com, info, spot); //adds item info getline(initem, com); if(com == "@@") { getline(initem, com); break; } } if(dude.itemExist(spot) == false) //makes sure item was actually added { dude.resetItem(spot); dude.resetStud(spot); spot--; } getline(initem, com); } bool answer; string com2; while(com != "quit") //importing commands { incom>>com; if(com == "delete") { incom>>info; answer = dude.delStud(info); //deletes the student outdata<>com2; //either student or item if(com2 == "student") { getline(incom, com); getline(incom, com); spot = -1; while(com != "@@") { getline(incom, info); dude.addStudent(com, info, spot); //adds new student getline(incom, com); } outdata<<"add student"<>com2; getline(incom, info); outdata<