/* Homework 0, An Order Processing System Programmer: Dan Bennett I had assistance from the entire 230 class. This program .... */ #include #include using namespace std; const string TRANSACTION_FILE_NAME = "orders.data"; void OpenTransactionFile(ifstream & theFile); void CloseTransactionFile(ifstream & transactionFile); string ReadOrderFromTransactionFile(ifstream & theFile); void ProcessOrder(string orderFileName); void ProcessOrder(ifstream & orderFile); int main() { string orderFileName; ifstream transactionFile; // Open transaction file OpenTransactionFile(transactionFile); // Read an order file name orderFileName = ReadOrderFromTransactionFile(transactionFile); // while not at the end of transaction file while (transactionFile) { // Process the order ProcessOrder(orderFileName); //cout << "Processing " << orderFileName << endl; // Read a new order file name orderFileName = ReadOrderFromTransactionFile(transactionFile); } // close the transaction file CloseTransactionFile(transactionFile); return 0; } void ProcessOrder(ifstream & orderFile) { cout << "Really processing the order " << endl; return; } void ProcessOrderFile(string fileName) { ifstream orderFile; orderFile.open(fileName); if (orderFile) { ProcessOrder(orderFile); orderFile.close(); } else { cout << "Unable to open" << fileName ; } return; } void OpenTransactionFile(ifstream & theFile){ theFile.open(TRANSACTION_FILE_NAME); return; } void CloseTransactionFile(ifstream & transactionFile){ transactionFile.close(); } string ReadOrderFromTransactionFile(ifstream & theFile){ string tmp; theFile >> tmp; return tmp; }