can anybody please help me make a program using text files for an airplane booking program with the following things included. Ticket number, Seat Number-A,B,C,D,E,F.(what i meant is like an airplane the seat number should be a number with any of the above letters and also the max limit is 50F if anything else is inserted then it should not be accepted)
Class of travel(ECONOMY,BUSINESS OR FIRST anything else should not be accepted.)
Also I have got a sample program of hotel management and I would be extremely grateful if you could make my program look like that with necessary changes.
class hotel
{
int room_no;
char name[30];
char address[50];
char phone[10];
public:
void main_menu(); //to dispay the main menu
void add(); //to book a room
void display(); //to display the customer record
void rooms(); //to display alloted rooms
void edit(); //to edit the customer record
int check(int); //to check room status
void modify(int); //to modify the record
void delete_rec(int); //to delete the record
};
void hotel::main_menu()
{
int choice;
while(choice!=5)
{
clrscr();
cout<<"\n\t\t\t\t*************";
cout<<"\n\t\t\t\t* MAIN MENU *";
cout<<"\n\t\t\t\t*************";
cout<<"\n\n\n\t\t\t1.Book A Room";
cout<<"\n\t\t\t2.Customer Record";
cout<<"\n\t\t\t3.Rooms Allotted";
cout<<"\n\t\t\t4.Edit Record";
cout<<"\n\t\t\t5.Exit";
cout<<"\n\n\t\t\tEnter Your Choice: ";
cin>>choice;
switch(choice)
{
case 1: add();
break;
case 2: display();
break;
case 3: rooms();
break;
case 4: edit();
break;
case 5: break;
default:
{
cout<<"\n\n\t\t\tWrong choice.....!!!";
cout<<"\n\t\t\tPress any key to continue....!!";
getch();
}
}
}
}
void hotel::add()
{
clrscr();
int r,flag;
ofstream fout("Record.dat",ios::app);
i have some suggestion for you, you're always free to ignore any:
the class called hotel might change its name to hotelRoom, as it describes one room of the hotel, you will then create another class called hotel, this one contains a private member ( vector<hotelRoom> book; ).
this might look like "re-structuring the whole program", but i think it's a better structure.
the hotel class shall manages the rooms inside it (make reservations, check for validity of a room, handle cash, ...etc), the hotelRoom class shall provide a good interface for manipulating its contents (default constructor for null initialization, setter functions ...etc).