Advertisement
adibahbab4108

C211009-ADIB

Oct 23rd, 2021
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.44 KB | None | 0 0
  1. #include<iostream>
  2. #include<stdlib.h>
  3. #include<fstream>
  4. #include<string>
  5. #include<conio.h>
  6. #include<windows.h>
  7. using namespace std;
  8. class Restaurent
  9. {
  10.     int Price,Amount;
  11.     string Name;
  12. public:
  13.     void set_Val(string name,int price,int quantity)
  14.     {
  15.         Name=name;
  16.         Price=price;
  17.         Amount=quantity;
  18.  
  19.     }
  20.  
  21.     void showmenu(int i)
  22.     {
  23.         cout<<"\t\t\t#"<<i<<endl;
  24.         cout<<"\t\t\tName: "<<Name<<endl;
  25.         cout<<"\t\t\tPrice: "<<Price<<endl;
  26.         cout<<"\t\t\tAmount: "<<Amount<<endl<<endl;
  27.  
  28.     }
  29.     void showbill(int j,int Q)
  30.     {
  31.         cout<<endl;
  32.         cout<<"\t\t\tYou have selected #"<<j<<endl;
  33.         cout<<"\t\t\tName: "<<Name<<endl;
  34.         cout<<"\t\t\tQuantity: "<<Q<<endl;
  35.         cout<<"\t\t\tTotal bill: "<<Q*Price<<endl;
  36.         cout<<"\t\t\tThank you!"<<endl;
  37.         system("color 2");
  38.         getch();
  39.     }
  40. };
  41. int main()
  42. {
  43. //...............OWNER PART................
  44.     Restaurent management[50];
  45.     ofstream RestaurentM;
  46.     int items1,price,quantity,i;
  47.     string name;
  48.     cout<<"\n\n\n\t\t\t\t================================================="<<endl;
  49.     cout<<"\t\t\t\t\t|  RESTAURENT MANAGEMENT SYSTEM  |"<<endl;
  50.     cout<<"\t\t\t\t=================================================\n"<<endl;
  51.     cout<<"\t\t\t1. Add new items\n\t\t\t2. skip\n\t\t\t3.Exit\n";
  52.     int choice2;
  53.     cout<<"\t\t\tSelect: ";
  54.     cin>>choice2;
  55.     if(choice2==1)
  56.     {
  57.         cout<<"\t\t\tHow many items:";
  58.         cin>>items1;
  59. //..........TAKING MENU FROM THE OWNER........
  60.         for(i=1; i<=items1; i++)
  61.         {
  62.             cout<<"\t\t\t#"<<i<<endl;
  63.             cout<<"\t\t\tName: ";
  64.             cin>>name;
  65.             cout<<"\t\t\tPrice: ";
  66.             cin>>price;
  67.             cout<<"\t\t\tAmount: ";
  68.             cin>>quantity;
  69.             management[i].set_Val(name,price,quantity);
  70.             RestaurentM.open("Restaurent Management copy.txt",ios::app|ios::out);
  71.             RestaurentM<<"\t\t\t#"<<i<<"\n\t\t\tName : "<<name<<"\n\t\t\tPrice: "<<price<<"\n\t\t\tamount: "<<quantity<<endl;
  72.             RestaurentM.close();
  73.         }
  74.     }
  75.     else if(choice2==2)
  76.         goto wlcmsg;
  77.     else if(choice2==3)
  78.     {
  79.         exit(0);
  80.     }
  81.  
  82.     system("cls");
  83.  
  84. //.................CUSTOMER PART..................
  85.  
  86. wlcmsg:
  87.     system("cls");
  88.     cout<<"\n\n\n\t\t\t\t| WELCOME TO RESTAURENT |"<<endl;
  89.     cout<<"\t\t\t=======================================\n"<<endl;
  90.     cout<<"\t\t\t1.See all items\n\t\t\t2.select"<<endl;
  91. //.....IF CUSTOMER WANT SEE ALL ITEMS......
  92.     int select;
  93.     cout<<"\t\t\tchoose: ";
  94.     cin>>select;
  95.     if(select==1)
  96.     {
  97.         int selected_item,Number_of_Plate;
  98. //......IF THE OWNER SELECT 'SKIP' OPTION, THEN THIS PART WILL BE EXECUTED....
  99.         /*        if(choice1==2)
  100.                 {
  101.                   for(i=1; i<=items1; i++)
  102.                     {
  103.                         management[i].showmenu(i);
  104.                     }
  105.                     cout<<endl;
  106.                 }
  107.         //....IF THE OWNER WANT TO SHOW MORE ADDED ITEMS,THEN THIS PART WILL BE EXECUTED....
  108.                 else if(choice1==1)
  109.                 {
  110.  
  111.             for(i=1; i<=items1+items2; i++)
  112.             {
  113.                 management[i].showmenu(i);
  114.             }
  115.             cout<<endl;
  116.                 }
  117.         */
  118.         ifstream RestaurentM;
  119.         string line_by_line;
  120.         RestaurentM.open("Restaurent Management copy.txt",ios::in);
  121.         if(RestaurentM.is_open())
  122.         {
  123.             while(getline(RestaurentM,line_by_line))
  124.             {
  125.                 cout<<line_by_line<<endl;
  126.             }
  127.             RestaurentM.close();
  128.         }
  129.         else
  130.         {
  131.             cout<<"\t\t\tFile is not found\n";
  132.             Sleep(1000);
  133.             goto wlcmsg;
  134.         }
  135.  
  136.         RestaurentM.close();
  137. S:
  138.         cout<<"\t\t\tselect items :";
  139.         cin>>selected_item;
  140.         if(selected_item>items1)
  141.         {
  142.             cout<<"\t\t\tInvalid choice!.\nPlease again ";
  143.             goto S;
  144.         }
  145.  
  146. q:
  147.         cout<<"\t\t\tquantity: ";
  148.         cin>>Number_of_Plate;
  149.         if(Number_of_Plate>quantity)
  150.         {
  151.             cout<<"\t\t\tSorry, we have "<<quantity<<" items available only.Please select not more than quantity"<<quantity<<endl;
  152.             goto q;
  153.         }
  154.         else
  155.         {
  156.             management[selected_item].showbill(selected_item,Number_of_Plate);
  157.         }
  158.     }
  159. }
  160.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement