A list of objects

I have a list of objects that I need to read information from each object to compare to a user input prompt.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "Passenger.h"
#include "Reservation.h"
#include "Aircraft.h"
#include <iostream>
#include <fstream>
#include <string>
#include <list>

using namespace std;

//Function Prototypes
void flightRoster(list<Reservation>&);

// Menu structure
enum AirlineMenu
{
	SHOWMENU, BOOK, REMOVE, PASS, FLIGHTSCH, EXIT
}airMenu;

int main()
{
	bool end = false;
	int option = 0;
	char cont = 'x';
	list<Reservation> allFlights;
	list<Reservation> bookedFlights;
	Passenger pass;

	flightRoster(allFlights);

	// New reservation inputs
	string f, l, ffP, dCity;

	//File variables
	fstream file2; /*file,*/
	//file.open("Reservation Info.txt");
	file2.open("Booked Reservations.txt");

	if (file2.fail()) /*file.fail() ||*/ 
	{
		cout << "Error opening a file or both..." << endl;
		system ("pause");
		exit(EXIT_SUCCESS);
	}

	while(!end)
	{
		switch(airMenu)
		{
		case SHOWMENU: // Main menu for the program

			cout << "------------------------------\n" 
				 << "[0]  Show Main Menu\n"
				 << "[1]  Book a reservation\n"
				 << "[2]  Cancel a reservation\n"
				 << "[3]  Display an individual boarding pass\n"
				 << "[4]  Display flight schedule\n"
				 << "[5]  Exit the program\n"
				 << "------------------------------\n";

			cin >> option;
			if (option == 0) airMenu = SHOWMENU;
			else if (option == 1) airMenu = BOOK;
			else if (option == 2) airMenu = REMOVE;
			else if (option == 3) airMenu = PASS;
			else if (option == 4) airMenu = FLIGHTSCH;
			else if (option == 5) airMenu = EXIT;
			else airMenu = SHOWMENU;

			break;

		case BOOK:

			cout << "Please enter the customers information: " << endl;
			do
			{
				// Input the customers information
				cout << "First Name: " << endl;
				cin >> f;

				cout << "Last Name: " << endl;
				cin >> l;

				cout << "Current Frequest Flyer Points: " << endl;
				cin >> ffP;

				cout << "Departure City: \n" << endl;
				cout << "Cities in database: \n" << endl;
				cout << "------------------------------\n" 
					 << "ATL 	Atlanta\n"
					 <<	"ORL 	Orlando\n"
					 <<	"DFW 	Dallas/Fort Worth\n"
					 <<	"NYC 	New York City\n"
					 <<	"HAW 	Hawaii\n"
					 <<	"CHI 	Chicago\n"
					 << "------------------------------\n";
				cin >> dCity;
				
				/*file2 << f;
				file2 << l;
				file2 << ffP;
				file2 << dCity;*/

				//Compare the user input for the destination city with the
				//information contained in the allFlights list

				cout << "Would you like to book another reservation ?" << endl;
				cout << "Enter X to input another reservation" << endl;
				cin >> cont;
			
			} while(cont == 'x' || cont == 'X');

			airMenu = SHOWMENU;
			break;
Last edited on
I have tried a string.compare and it did not work would there be any other way to achieve what I need to do
Topic archived. No new replies allowed.