// TestFlight.cpp // // Chris Nevison // May 12, 2002 // // Solution to the Advanced Placement Computer Science // A exam, free response question 4 // // Main program to test classes. #include #include #include using namespace std; #include "Flight.h" #include "Seat.h" #include "Passenger.h" int main() { apstring filename; ifstream in; cout << "Enter file name for flight: "; cin >> filename; in.open(filename.c_str()); Flight flt(in); flt.ShowFlight(cout); cout << endl; cout << "Number of window seats empty = " << flt.EmptySeatCount("window") << endl; cout << "Number of aisle seats empty = " << flt.EmptySeatCount("aisle") << endl; cout << "Number of middle seats empty = " << flt.EmptySeatCount("middle") << endl; cout << "Number of seats empty = " << flt.EmptySeatCount("any") << endl << endl; cout << "Block of 1 in row 0 starts at seat " << flt.FindBlock(0, 1) << endl; cout << "Block of 1 in row 1 starts at seat " << flt.FindBlock(1, 1) << endl; cout << "Block of 2 in row 0 starts at seat " << flt.FindBlock(0, 2) << endl; cout << "Block of 2 in row 1 starts at seat " << flt.FindBlock(1, 2) << endl; cout << "Enter filename for groups: "; cin >> filename; in.close(); in.open(filename.c_str()); int numGroups; int grp; in >> numGroups; for(grp = 0; grp < numGroups; grp++) { int numInGroup; int k; apstring name; in >> numInGroup; apvector group(numInGroup); for(k = 0; k < numInGroup; k++) { in >> name; group[k] = Passenger(name); } if(flt.AssignGroup(group)) { flt.ShowFlight(cout); } else { cout << "Group " << grp << " not assigned." << endl; } } return 0; }