/*
File name: hw7.cpp
Author: Bo Bayles
E-mail address: bmb3h6@umr.edu
Description: This program keeps track of the data for flights entered
  by the user, then sorts and displays them based on user-selected
  criteria.
*/

#include "hw8.h"
#include <iostream>
#include <fstream>
using namespace std;


int main()
{
  int iFlights = 0;
  char cMenu;
  Flight flights[50];
  
  ifstream inFile;
  ofstream outFile;
  
  inFile.open("flights.txt");
  outFile.open("flights.out");
  //Declare and open input and output file streams.
  
  if (!inFile.fail())
  //Make sure the file opened properly.
  {
            
  do
  {
    cMenu = DisplayMenu();

    switch (cMenu)
    {
      case '1':
              AddFlight(flights, iFlights, inFile);
              break;

      case '2':
              selectSort(flights, iFlights, 2);
              DispFlights(flights, iFlights, outFile);
              DispFlights(flights, iFlights, cout);
              //Call selectSort with the 2 and the ifstream, then
              //  DispFlights once with the ofstream and once with cout.
              break;

      case '3':
              selectSort(flights, iFlights, 3);
              DispFlights(flights, iFlights, outFile);
              DispFlights(flights, iFlights, cout);
              break;

      case '4':
              selectSort(flights, iFlights, 4);
              DispFlights(flights, iFlights, outFile);
              DispFlights(flights, iFlights, cout);
              break;

      case '5':
              findDirect(flights, iFlights);
              //Call findDirect.
              break;

      case '6':
              break;

      default:
             cout << endl << "Invalid entry." << endl;
             break;
             //Catch bad entries.
    }
  }
  while(cMenu != '6');
  //Loop until the user chooses to quit.

  }
  else
    cout << "Error opening file." << endl;

  inFile.close();
  outFile.close();
  cout << endl << "Exiting..." << endl;
  return 0;
}

