IMohammedNasr

Untitled

Apr 23rd, 2022
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 22.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string.h>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <cmath>
  7. #include <conio.h>
  8. using namespace std;
  9. int holder_re = 1;
  10.  
  11. // class order
  12. // {
  13. // public:
  14. //     int id, price;
  15. //     char name[10];
  16. // };
  17. class order
  18. {
  19. public:
  20.     int id, price, amount;
  21.     char name[10];
  22.     order()
  23.     {
  24.         id = price = 0;
  25.         amount = 1;
  26.         strcpy(name, "");
  27.     }
  28. };
  29. class admins
  30. {
  31. public:
  32.     char name[20], password[20];
  33. };
  34. void coutWell(string s, bool no)
  35. {
  36.     int space = 25;
  37.     int ast = 50;
  38.     int n = s.size();
  39.     if (no)
  40.         s = '~' + s;
  41.     int last = 7;
  42.     for (int j = 0; j < last; j++)
  43.     {
  44.         for (int i = 0; i < space; i++)
  45.             cout << " ";
  46.         if (j == 0 || j == last - 1)
  47.         {
  48.             for (int i = 0; i < ast; i++)
  49.                 cout << "*";
  50.         }
  51.         else if (j == last / 2)
  52.         {
  53.             cout << '*';
  54.             int test = ast - 2;
  55.             test /= 2;
  56.             test -= n / 2;
  57.             for (int i = 0; i < test; i++)
  58.                 cout << " ";
  59.             cout << s;
  60.             if (no == 0)
  61.                 test--;
  62.             for (int i = 0; i < ast - test - n - 3; i++)
  63.                 cout << " ";
  64.             cout << "*";
  65.         }
  66.         else
  67.         {
  68.             cout << "*";
  69.             for (int i = 0; i < ast - 2; i++)
  70.                 cout << " ";
  71.             cout << "*";
  72.         }
  73.         for (int i = 0; i < space; i++)
  74.             cout << " ";
  75.         cout << "\n";
  76.     }
  77. }
  78. void coutProducts(vector<string> &s, bool no)
  79. {
  80.     int ast = 100;
  81.     int n = s.size();
  82.     for (int j = 0; j < n + 2; j++)
  83.     {
  84.         for (int i = 0; i < 20; i++)
  85.             cout << " ";
  86.         if (j == 0 || j == n + 1)
  87.         {
  88.             for (int i = 0; i < ast; i++)
  89.                 cout << "*";
  90.             cout << "\n";
  91.             continue;
  92.         }
  93.         if (!no)
  94.         {
  95.             int cnt = 6 + (int)log10(j) + 1;
  96.             cout << "* " << j << " - ";
  97.             for (int i = 0; i < (int)s[j - 1].size(); i++)
  98.             {
  99.                 if (i < s[j - 1].size())
  100.                     cout << s[j - 1][i], cnt++;
  101.             }
  102.             for (int i = 0; i < ast - cnt; i++)
  103.                 cout << " ";
  104.             cout << "*\n";
  105.         }
  106.         else
  107.         {
  108.             string test;
  109.             int cnt = 3;
  110.             cout << "* ";
  111.             for (int i = 0; i < (int)s[j - 1].size(); i++)
  112.             {
  113.                 if (s[j - 1][i] != ' ')
  114.                 {
  115.                     while (i < (int)s[j - 1].size() && s[j - 1][i] != ' ')
  116.                     {
  117.                         test += s[j - 1][i];
  118.                         i++;
  119.                         cnt++;
  120.                     }
  121.                     i--;
  122.                     cout << test;
  123.                     for (int k = 0; k < 20 - (int)test.size(); k++)
  124.                     {
  125.                         cout << " ";
  126.                         cnt++;
  127.                     }
  128.                     test.clear();
  129.                 }
  130.                 else
  131.                     continue;
  132.             }
  133.             for (int i = 0; i < ast - cnt; i++)
  134.                 cout << " ";
  135.             cout << "*\n";
  136.         }
  137.     }
  138. }
  139. // *******************************************************ADMIN INTERFACE*******************************************************
  140. // add admin
  141. void addadmin()
  142. {
  143.     system("cls");
  144.     coutWell("SIGNUP", 1);
  145.     fstream outfile;
  146.     outfile.open("admin.txt", ios::out | ios::app);
  147.     admins s1;
  148.     cout << "Enter Your USERNAME: ";
  149.     cin >> s1.name;
  150.     char test[20];
  151.     bool again = false;
  152.     do
  153.     {
  154.         if (again)
  155.             cout << "\n\nTwo PASSWORDS are not the same, please try again...\n";
  156.         cout << "Enter Your PASSWORD: ";
  157.         for (int i = 0; i < 20; i++)
  158.         {
  159.             s1.password[i] = _getch();
  160.             if (s1.password[i] == 13)
  161.             {
  162.                 s1.password[i] = '\0';
  163.                 break;
  164.             }
  165.             putch('*');
  166.         }
  167.         char test2[20];
  168.         strcpy(test, test2);
  169.         cout << "\nEnter Your PASSWORD again: ";
  170.         for (int i = 0; i < 20; i++)
  171.         {
  172.             test[i] = _getch();
  173.             if (test[i] == 13)
  174.             {
  175.                 test[i] = '\0';
  176.                 break;
  177.             }
  178.             putch('*');
  179.         }
  180.     } while (strcmp(test, s1.password) && (again = true));
  181.     outfile.write((char *)&s1, sizeof(s1));
  182.     outfile.close();
  183.     system("cls");
  184.     cout << "Signed up successfully, please reopen again";
  185.     for (int i = 0; i < 500000000;)
  186.     {
  187.         if (i == 100000000 || i == 200000000 || i == 300000000 || i == 400000000)
  188.             cout << ".";
  189.         i++;
  190.         if (i == 500000000 - 1)
  191.             cout << "\n";
  192.     }
  193. }
  194.  
  195. // check if admin.txt isn't empty txt file (if it's empty, we must add an admin with the previous function)
  196. bool check_empty()
  197. {
  198.     fstream infile;
  199.     infile.open("admin.txt", ios::in);
  200.     if (infile.peek() == EOF)
  201.     {
  202.         infile.close();
  203.         return false;
  204.     }
  205.     infile.close();
  206.     return true;
  207. }
  208.  
  209. // check if given id matches given password in admin.txt (if wrong 3 times then the program will be closed)
  210. bool check_admin()
  211. {
  212.     char i[20];
  213.     char s[20];
  214.     cout << "Enter Your USERNAME: ";
  215.     cin >> i;
  216.     cout << "Enter PASSWORD: ";
  217.     for (int i = 0; i < 20; i++)
  218.     {
  219.         s[i] = _getch();
  220.         if (s[i] == 13)
  221.         {
  222.             s[i] = '\0';
  223.             break;
  224.         }
  225.         putch('*');
  226.     }
  227.     fstream infile;
  228.     infile.open("admin.txt", ios::in);
  229.     admins s1;
  230.     while (!infile.eof())
  231.     {
  232.         infile.read((char *)&s1, sizeof(s1));
  233.         if (strcmp(s1.name, i) == 0)
  234.         {
  235.             if (strcmp(s1.password, s) == 0)
  236.             {
  237.                 infile.close();
  238.                 return true;
  239.             }
  240.             else
  241.             {
  242.                 infile.close();
  243.                 return false;
  244.             }
  245.         }
  246.     }
  247.     infile.close();
  248.     return false;
  249. }
  250.  
  251. void readorder()
  252. {
  253.     system("cls");
  254.     order s1;
  255.     ifstream read;
  256.     read.open("order.txt", ios::in);
  257.     vector<string> s;
  258.     if (read.is_open())
  259.     {
  260.         s.push_back("ID Name price");
  261.         read.read((char *)&s1, sizeof(s1));
  262.         while (!read.eof())
  263.         {
  264.             s.push_back(to_string(s1.id) + " " + s1.name + " " + to_string(s1.price));
  265.             read.read((char *)&s1, sizeof(s1));
  266.         }
  267.         read.close();
  268.         coutProducts(s, 1);
  269.     }
  270.     else
  271.     {
  272.         coutWell("the file can not open", 1);
  273.     }
  274. }
  275. void writeorder()
  276. {
  277.     system("cls");
  278.     coutWell("New Order", 1);
  279.     fstream outfile;
  280.     outfile.open("order.txt", ios::out | ios::app);
  281.     char c;
  282.     do
  283.     {
  284.         order s1;
  285.         cout << "Enter ID: ";
  286.         cin >> s1.id;
  287.         cout << "Enter NAME: ";
  288.         cin >> s1.name;
  289.         cout << "Enter price: ";
  290.         cin >> s1.price;
  291.         outfile.write((char *)&s1, sizeof(s1));
  292.         cout << "Enter another order (y/n): ";
  293.         cin >> c;
  294.     } while (c == 'y');
  295.     outfile.close();
  296. }
  297. void search()
  298. {
  299.     system("cls");
  300.     char str[10];
  301.     cout << "Enter name to search: " << endl;
  302.     cin >> str;
  303.     bool found = false;
  304.     order s1;
  305.     ifstream read;
  306.     read.open("order.txt", ios::in);
  307.     if (read.is_open())
  308.     {
  309.         read.read((char *)&s1, sizeof(s1));
  310.         while (!read.eof())
  311.         {
  312.             if (strcmp(str, s1.name) == 0)
  313.             {
  314.                 cout << "ID\tName\tprice" << endl;
  315.                 cout << s1.id << "\t" << s1.name << "\t" << s1.price << endl;
  316.                 found = true;
  317.             }
  318.             read.read((char *)&s1, sizeof(s1));
  319.         }
  320.         if (!found)
  321.         {
  322.             cout << "name not found " << endl;
  323.         }
  324.         read.close();
  325.     }
  326.     else
  327.     {
  328.         cout << "the file can not open" << endl;
  329.     }
  330.     char contin;
  331.     cout << "Enter any key to continue....  ";
  332.     cin >> contin;
  333. }
  334.  
  335. void updateorder()
  336. {
  337.     readorder();
  338.     char str[10];
  339.     cout << "Enter name for search: " << endl;
  340.     cin >> str;
  341.     bool found = false;
  342.     order s1;
  343.     fstream in;
  344.     in.open("order.txt", ios::in | ios::out);
  345.     if (in.is_open())
  346.     {
  347.         in.read((char *)&s1, sizeof(s1));
  348.         while (!in.eof())
  349.         {
  350.             if (strcmp(str, s1.name) == 0)
  351.             {
  352.                 cout << "Enter the new price of:" << str << " ";
  353.                 cin >> s1.price;
  354.                 int curPos = in.tellg();
  355.                 int stuSize = sizeof(s1);
  356.                 in.seekp(curPos - stuSize, ios::beg);
  357.                 in.write((char *)&s1, sizeof(s1));
  358.                 in.seekp(curPos - stuSize, ios::beg);
  359.                 in.read((char *)&s1, sizeof(s1));
  360.                 cout << "ID\tName\tprice" << endl;
  361.                 cout << s1.id << "\t" << s1.name << "\t" << s1.price << endl;
  362.                 found = true;
  363.             }
  364.             in.read((char *)&s1, sizeof(s1));
  365.         }
  366.         if (!found)
  367.         {
  368.             cout << "name not found " << endl;
  369.         }
  370.         in.close();
  371.     }
  372.     else
  373.     {
  374.         cout << "the file can not open" << endl;
  375.     }
  376.     char contin;
  377.     cout << "Enter any key to continue....  ";
  378.     cin >> contin;
  379. }
  380.  
  381. void copyFile()
  382. {
  383.     ifstream in("order.txt"); // order = text
  384.     ofstream out("copy text.txt");
  385.     if (in.is_open())
  386.     {
  387.         char ch;
  388.         while (in.get(ch))
  389.             out.put(ch);
  390.         in.close();
  391.         out.close();
  392.     }
  393.     cout << "Copied successfully ";
  394.     for (int i = 0; i < 300000000; i++)
  395.     {
  396.         if (i == 100000000 || i == 200000000)
  397.             cout << ".";
  398.     }
  399.     cout << "\n";
  400. }
  401.  
  402. void deleteorder()
  403. {
  404.     readorder();
  405.     char str[10];
  406.     cout << "Enter name for search: " << endl;
  407.     cin >> str;
  408.     bool found = false;
  409.     order s1;
  410.     ifstream in("order.txt", ios::in);
  411.     ofstream out("temp.txt", ios::out);
  412.     if (in.is_open())
  413.     {
  414.         in.read((char *)&s1, sizeof(s1));
  415.         while (!in.eof())
  416.         {
  417.             if (strcmp(str, s1.name) != 0)
  418.             {
  419.                 out.write((char *)&s1, sizeof(s1));
  420.                 found = true;
  421.             }
  422.             in.read((char *)&s1, sizeof(s1));
  423.         }
  424.         if (!found)
  425.         {
  426.             cout << "name not found " << endl;
  427.         }
  428.         in.close();
  429.         out.close();
  430.         remove("order.txt");
  431.         rename("temp.txt", "order.txt");
  432.     }
  433.     else
  434.     {
  435.         cout << "the file can not open" << endl;
  436.     }
  437.     readorder();
  438. }
  439. void fix()
  440. {
  441.     fstream file;
  442.     file.open("order.txt", ios::in | ios::out);
  443.     ofstream testt;
  444.     vector<order> nums;
  445.     order o1;
  446.     if (file.is_open())
  447.     {
  448.         while (!file.eof())
  449.         {
  450.             file.read((char *)&o1, sizeof(o1));
  451.             nums.push_back(o1);
  452.         }
  453.         file.close();
  454.         testt.open("order.txt", ios::out);
  455.         for (int i = 0; i < (int)nums.size() - 1; i++)
  456.         {
  457.             nums[i].id = i + 1;
  458.             testt.write((char *)&nums[i], sizeof(nums[i]));
  459.         }
  460.         testt.close();
  461.     }
  462. }
  463. // *****************************************************USER INTERFACE****************************************************
  464.  
  465. // shows user's selections
  466. void readselections()
  467. {
  468.     order s1;
  469.     ifstream read;
  470.     read.open("selections.txt", ios::in);
  471.     vector<string> s;
  472.     if (read.is_open())
  473.     {
  474.         s.push_back("ID          Name          price          amount");
  475.         read.read((char *)&s1, sizeof(s1));
  476.         while (!read.eof())
  477.         {
  478.             s.push_back(to_string(s1.id) + "          " + s1.name + "          " + to_string(s1.price) + "          " + to_string(s1.amount));
  479.             read.read((char *)&s1, sizeof(s1));
  480.         }
  481.         read.close();
  482.         coutProducts(s, 1);
  483.     }
  484.     else
  485.     {
  486.         coutWell("the file can not open", 1);
  487.     }
  488. }
  489.  
  490. // function that counts all the prince in selections.txt and return the total price
  491. int total_price()
  492. {
  493.     int total = 0;
  494.     order s1;
  495.     ifstream read;
  496.     read.open("selections.txt", ios::in);
  497.     if (read.is_open())
  498.     {
  499.         read.read((char *)&s1, sizeof(s1));
  500.         while (!read.eof())
  501.         {
  502.             total += (s1.price * s1.amount);
  503.             read.read((char *)&s1, sizeof(s1));
  504.         }
  505.         read.close();
  506.     }
  507.     return total;
  508. }
  509.  
  510. // copy selections.txt to temp.txt to count the new amount of each item after adjusting the amount
  511. void increase_amount(char name[], int amount, bool adding = true)
  512. {
  513.     order s1;
  514.     ifstream read;
  515.     read.open("selections.txt", ios::in);
  516.     if (read.is_open())
  517.     {
  518.         read.read((char *)&s1, sizeof(s1));
  519.         while (!read.eof())
  520.         {
  521.             if (strcmp(s1.name, name) == 0)
  522.             {
  523.                 if (amount == s1.amount)
  524.                 {
  525.                     read.read((char *)&s1, sizeof(s1));
  526.                     continue;
  527.                 }
  528.                 else if (adding == true)
  529.                     s1.amount += amount;
  530.                 else
  531.                 {
  532.                     while (amount > s1.amount and !adding)
  533.                     {
  534.                         cout << "Invalid amount please try again: ";
  535.                         cin >> amount;
  536.                     }
  537.                     if (amount == s1.amount)
  538.                     {
  539.                         read.read((char *)&s1, sizeof(s1));
  540.                         continue;
  541.                     }
  542.                     s1.amount -= amount;
  543.                 }
  544.             }
  545.             fstream outfile;
  546.             outfile.open("temp.txt", ios::out | ios::app);
  547.             outfile.write((char *)&s1, sizeof(s1));
  548.             outfile.close();
  549.             read.read((char *)&s1, sizeof(s1));
  550.         }
  551.         read.close();
  552.     }
  553.     remove("selections.txt");
  554.     rename("temp.txt", "selections.txt");
  555. }
  556.  
  557. // we search for the giving id in order.txt file so we get its name and send it to the previous function (changing the flag to false)
  558. void delete_selection(int id, int amount)
  559. {
  560.     int i = 1;
  561.     order s1;
  562.     ifstream read;
  563.     read.open("order.txt", ios::in);
  564.     if (read.is_open())
  565.     {
  566.         read.read((char *)&s1, sizeof(s1));
  567.         while (!read.eof())
  568.         {
  569.             if (s1.id == id)
  570.             {
  571.                 // if we didn't change to false he'll add the amount not subtract it
  572.                 increase_amount(s1.name, amount, false);
  573.                 return;
  574.             }
  575.             read.read((char *)&s1, sizeof(s1));
  576.         }
  577.         read.close();
  578.     }
  579. }
  580.  
  581. // read all the selection file and determine if the item is already in or not and if it is we add the amount to it
  582. bool search_name_selection(char name[])
  583. {
  584.     order s1;
  585.     ifstream read;
  586.     read.open("selections.txt", ios::in);
  587.     if (read.is_open())
  588.     {
  589.         read.read((char *)&s1, sizeof(s1));
  590.         while (!read.eof())
  591.         {
  592.             if (strcmp(s1.name, name) == 0)
  593.             {
  594.                 read.close();
  595.                 return true;
  596.             }
  597.             read.read((char *)&s1, sizeof(s1));
  598.         }
  599.         read.close();
  600.     }
  601.     return false;
  602. }
  603.  
  604. // we get the id and amount of the item that user wants and check with the functions we have it's already exists or not
  605. // and if it's not we add it to the selections.txt file and if it's already exists we add the amount to it
  606. void increase_amount_id()
  607. {
  608.     int id, amount, id_holder;
  609.     cout << "what is the order you want: ";
  610.     cin >> id;
  611.     cout << "how many do you want: ";
  612.     cin >> amount;
  613.     order s1;
  614.     ifstream read;
  615.     read.open("order.txt", ios::in);
  616.     if (read.is_open())
  617.     {
  618.         read.read((char *)&s1, sizeof(s1));
  619.         while (!read.eof())
  620.         {
  621.             if (s1.id == id)
  622.             {
  623.                 if (search_name_selection(s1.name))
  624.                     increase_amount(s1.name, amount);
  625.                 else
  626.                 {
  627.                     fstream outfile;
  628.                     s1.amount = amount;
  629.                     outfile.open("selections.txt", ios::out | ios::app);
  630.                     outfile.write((char *)&s1, sizeof(s1));
  631.                     outfile.close();
  632.                     s1.amount = 1;
  633.                     break;
  634.                 }
  635.             }
  636.             read.read((char *)&s1, sizeof(s1));
  637.         }
  638.         read.close();
  639.     }
  640. }
  641.  
  642. // delete all the selections because the user finished the order
  643. void empty_selections()
  644. {
  645.     fstream outfile;
  646.     outfile.open("selections.txt", ios::out | ios::trunc);
  647.     outfile.close();
  648. }
  649.  
  650. // otro? m4 3arf asmha aeh lol (exiting interface)
  651. void complete_order()
  652. {
  653.     system("cls");
  654.     cout << "The total price is: " << total_price() << endl;
  655.     cout << "Thank you for visiting our restruant" << endl;
  656.     cout << "Hope for you a good day" << endl;
  657.     for (int i = 0; i < 500000000; i++)
  658.     {
  659.         if (i == 100000000 || i == 200000000 || i == 300000000 || i == 400000000)
  660.             cout << ".";
  661.     }
  662.     cout << "\n";
  663.     empty_selections();
  664. }
  665.  
  666. //******************************************************************************************************
  667.  
  668. int main()
  669. {
  670.     int admin;
  671. lable:
  672.     system("cls");
  673.     coutWell("1- Admin   //    2- customer", 0);
  674.     cout << "Please enter you choice : ";
  675.     cin >> admin;
  676.     char ch;
  677.     if (admin == 1)
  678.     {
  679.         char add_anoter_admin = 'n';
  680.         if (!check_empty())
  681.         {
  682.             addadmin();
  683.         }
  684.         else
  685.         {
  686.             system("cls"),
  687.                 coutWell("SIGNIN", 1);
  688.             int cnt = 0;
  689.         retry:
  690.             bool flag = check_admin();
  691.             if (!flag)
  692.             {
  693.                 if (cnt > 0)
  694.                     system("cls"),
  695.                         coutWell("SIGNIN", 1);
  696.                 cout << "invalid id or password" << endl;
  697.                 cnt++;
  698.                 if (cnt == 3)
  699.                 {
  700.                     cout << "you have entered wrong password 3 times" << endl;
  701.                     return 0;
  702.                 }
  703.                 goto retry;
  704.             }
  705.             system("CLS");
  706.             if (flag)
  707.             {
  708.                 do
  709.                 {
  710.                     system("CLS");
  711.                     vector<string> s =
  712.                         {
  713.                             "add a new order",
  714.                             "view the menu",
  715.                             "search in menu",
  716.                             "update the menu",
  717.                             "copy the menu",
  718.                             "delete an order",
  719.                             "Sign out"};
  720.                     coutProducts(s, 0);
  721.                     cout << "Select your choice: ";
  722.                     cin >> ch;
  723.                     switch (ch)
  724.                     {
  725.                     case '1':
  726.                         writeorder();
  727.                         fix();
  728.                         break;
  729.                     case '2':
  730.                         readorder();
  731.                         char x;
  732.                         cout << "Enter any key to continue.....  ";
  733.                         cin >> x;
  734.                         break;
  735.                     case '3':
  736.                         search();
  737.                         break;
  738.                     case '4':
  739.                         updateorder();
  740.                         fix();
  741.                         break;
  742.                     case '5':
  743.                         copyFile();
  744.                         break;
  745.                     case '6':
  746.                         deleteorder();
  747.                         fix();
  748.                         break;
  749.                     case '7':
  750.                         goto lable;
  751.                         break;
  752.                     default:
  753.                         cout << "invalid choice" << endl;
  754.                     }
  755.                 } while (ch != '7');
  756.             }
  757.         }
  758.     }
  759.     else
  760.     {
  761.         // customer view
  762.         do
  763.         {
  764.         menu:
  765.             system("CLS");
  766.             vector<string> s = {
  767.                 "Welcome",
  768.                 "1 - View menu",
  769.                 "2 - Sign out"};
  770.             coutProducts(s, 1);
  771.             cin >> ch;
  772.             switch (ch)
  773.             {
  774.             case '1':
  775.                 int tomenu;
  776.                 cout << "\n\n";
  777.                 readorder();
  778.                 cout << "\n\n";
  779.                 cout << "1. add an order: " << '\n';
  780.                 cout << "2. show selected order: " << '\n';
  781.                 cout << "3. go back to main menu: " << '\n';
  782.                 cout << "4. complete order: " << '\n';
  783.                 cout << "\n\nyour total price is: " << total_price() << '\n';
  784.             tryagain:
  785.                 cout << "Enter your choice: ";
  786.                 cin >> tomenu;
  787.                 if (tomenu == 1)
  788.                     increase_amount_id();
  789.                 else if (tomenu == 2)
  790.                 {
  791.                     system("CLS");
  792.                     readselections();
  793.                     int holder;
  794.                     cout << "\n\n";
  795.                     cout << "1. go back to main menu: \n";
  796.                     cout << "2. delete an order: \n";
  797.                     cout << "3. complete order: \n";
  798.                     cout << "Enter your choice: ";
  799.                     cin >> holder;
  800.                     if (holder == 1)
  801.                         goto menu;
  802.                     else if (holder == 2)
  803.                     {
  804.                         system("CLS");
  805.                         readselections();
  806.                         int id, amount;
  807.                         cout << "Enter the id of the order you want to delete: ";
  808.                         cin >> id;
  809.                         cout << "Enter the amount of the order you want to delete: ";
  810.                         cin >> amount;
  811.                         delete_selection(id, amount);
  812.                     }
  813.                     else if (holder == 3)
  814.                         complete_order();
  815.                     else
  816.                         cout << "invalid choice";
  817.                 }
  818.                 else if (tomenu == 3)
  819.                     goto menu;
  820.                 else if (tomenu == 4)
  821.                     complete_order();
  822.                 else
  823.                 {
  824.                     cout << "invalid choice" << endl;
  825.                     goto tryagain;
  826.                 }
  827.                 goto menu;
  828.                 break;
  829.             case '2':
  830.                 goto lable;
  831.                 break;
  832.             default:
  833.                 cout << "invalid choice" << endl;
  834.             }
  835.         } while (ch != '2');
  836.     }
  837.     return 0;
  838. }
Advertisement
Add Comment
Please, Sign In to add comment