#include #include #include using namespace std; #include "array.h" int main() { ifstream file; file.open("commands.data"); array myArray; ofstream out; out.open("out.txt"); char command[20]; char parameter[50]; char i[20] = " "; char m[20] = " "; char b[20] = " "; char o[20] = " "; char p[20] = " "; char a[20] = " "; char n[20] = " "; char ph[20] = " "; char e[20] = " "; char a1[20] = " "; char a2[20] = " "; char c[20] = " "; char s[20] = " "; char z[20] = " "; char ot[20] = " "; while (!file.eof()) { char subject[20] = ""; char command[20] = ""; char parameter[20] = ""; file >> command; file >> parameter; out << command << " " << parameter << endl; if ( strcmp(command, "delete") == 0 ) { bool success; success = myArray.delete_entry(parameter); if (success == true) out << "Success" << endl; else out << "Failure" << endl; } else if ( strcmp(parameter, "students") == 0 ) { myArray.print_students(out); } else if ( strcmp(parameter, "items") == 0 ) { myArray.print_items(out); } else if ( strcmp(command, "print") == 0 && strcmp(parameter, "students") != 0 && strcmp(parameter, "items") != 0 ) { myArray.print_email(parameter, out); } else if ( strcmp(parameter, "item") == 0 ) { int y = 0; bool success; file >> subject; while( strcmp(subject, "@@") != 0 ) { if (subject[1] == 'I') file >> i; //file.getline(i, 20, '\n'); if (subject[1] == 'M') file >> m; //file.getline(m, 20, '\n'); if (subject[1] == 'b') file >> b; //file.getline(b, 20, '\n'); if (subject[1] == 'O') { file >> o; //file.getline(o, 20, '\n'); y = 1; } if (subject[1] == 'P') file >> p; //file.getline(p, 20, '\n'); if (subject[1] == 'A') file >> a; //file.getline(a, 20, '\n'); file >> subject; }// { end while loop} if (y == 1) { success = myArray.add_item(i,m, b, o, p, a); if (success == true) out << "Success" << endl; else out << "Failure" << endl; } else out << "Failure" << endl; } else if ( strcmp(parameter, "student") == 0 ) { int y = 0; bool success; //file.getline(subject, 20, '\n'); file >> subject; while( subject[1] != '@' ) { if (subject[1] == 'N') //file.getline(n, 20, '\n'); file >> n; else if (subject[1] == 'P') file >> ph; //file.getline(ph, 20, '\n'); else if (subject[1] == 'E') { file >> e; //file.getline(e, 20, '\n'); y = 1; } else if ((subject[1] == 'A') && (subject[14] == '1')) file >> a1; //file.getline(a1, 20, '\n'); else if ((subject[1] == 'A') && (subject[14] == '2')) file >> a2; //file.getline(a2, 20, '\n'); else if (subject[1] == 'C') file >> c; //file.getline(c, 20, '\n'); else if (subject[1] == 'S') file >> s; //file.getline(s, 20, '\n'); else if (subject[1] == 'Z') file >> z; //file.getline(z, 20, '\n'); else if (subject[1] == 'O') file >> ot; //file.getline(ot, 100, '\n'); //file.getline(subject, 20, '\n'); file >> subject; }// { end while loop} if ( y == 1 ) { success = myArray.add_student(n, ph, e, a1, a1, c, s, z, ot); if (success == true) out << "Success" << endl; else out << "Failure" << endl; } else out << "Failure" << endl; } else if ( strcmp(command, "quit") == 0 ) return 0; } file.close(); return 0; }