I need help writing a program for an airline reservation system that inputs and outputs the first name, last name, flight number, and boarding priority (Platinum, Gold, Silver, or Lead). From my lecture notes, this is what I've written so far. I ran it by my professor and he said the structure was correct but after trying to run it on Visual Studio 2015, I noticed a few errors. The programs compiles and runs, but as soon as I enter a name, the code goes haywire on me. I'm sure the error is happening in the void Airlines::appendNode() portion of the code, but am unsure what is incorrect. Please help
Most of the code deals with the Airlines::PassengerInfo class, not the Airlines class. So lets start by moving the appropriate code there. By the way, I changed strcpy_s to strcpy since strcpy_s doesn't seem to be in the standard.
class Airlines
{
int pass_count;
struct PassengerInfo
{
char FName[NAME];
char LName[NAME];
char Priority[PSIZE];
int FltNum;
void read();
void selectPriority();
void display();
};
class List
{
struct ListNode
{
PassengerInfo value;
ListNode* next;
};
ListNode* head;
public:
List() { head = NULL; }
void appendNode(const PassengerInfo &);
void insertNode(const PassengerInfo &);
void deleteNode(const PassengerInfo &);
void displayList();
};
Modify the appendNode, insertNode and deleteNode methods. Then change Airlines::p_info array to List p_info and figure how to change each of the places in the code where p_info appears.
In a previous assignment, we were to do the same thing, but implement it using an array. This is somewhat what my professor was looking for in that assignment:
Okay, so you've replaced PassengerInfo with ListNode and added ListNode *next and double value to the struct.
What is the purpose of double value?
Why do appendNode() and insertNode() take a double as a parameter?
Why does displayList() display value?
The answer is that the code you're using as an example is a list of doubles. What you want is a list of PassengerInfo's So conceptually, you want to replacedouble value in the list with PassengerInfo value.
Now look back at my first post. That's exactly what I've suggested.
I cannot use your version because it doesn't follow the structure my code is supposed to be in. I need help with the code I have written here; it works (sorta). When I compile and run it, as soon as I enter the first name it glitches and jumps to the menu and then it becomes a mess. I'm not sure what is causing this.
I came across this code in my notes which somewhat does what I need; void push() acts like void Airlines::appendNode() and void pop() acts like void Airlines::displayReservation(void) (but it doesn't display all the entries, which is what I need my program to do). How would I go about implementing this in my code above to get it to work how I need it to?
You create one character and store the value 50 in it. Is this what you want?
Do you maybe want to create a character array to store the name?
Should be char FName[NAME]; then.
I cannot use your version because it doesn't follow the structure my code is supposed to be in
but did you at least try and customize it for your needs and, if so, where did it fail? or did you study the code and see how it could be applied to your context? it's not always possible to get exactly what you want