Advertisement
barbos01

Untitled

Oct 14th, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.80 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Lemon
  6. {
  7.     int lamai, zahar;
  8.     float suma;
  9. public:
  10.     void init(int l, int c, float s);
  11.     void afisare_ingrediente();
  12.     void limonada_neindulcita();
  13.     void limonada_indulcita();
  14.     void suma_incasata();
  15.  
  16. };
  17.  
  18. void Lemon::init(int l, int c, float s = 0)
  19. {   cout<<"Introduceti numarul de lamai: ";cin>>l;
  20.     cout<<"Introduceti numarul de cuburi de zahar: ";cin>>c;cout<<endl;
  21.     lamai  = l;
  22.     zahar = c;
  23.     suma = s;
  24. }
  25.  
  26. void Lemon::limonada_neindulcita()
  27. {
  28.     if(lamai <= 0)
  29.     {
  30.         cout<<"Ingrediente lipsta!\n";
  31.         cout<<"Suma incasata este: "<<suma<<" lei\n";
  32.         exit(0);
  33.     }
  34.     else
  35.     {
  36.         lamai--;
  37.         suma +=3;
  38.         cout<<"`````````````````````````````````\n";
  39.         cout<<"Ai primit o limodata neindulcita!\n";
  40.         cout<<"`````````````````````````````````\n";
  41.     }
  42.  
  43. }
  44.  
  45. void Lemon::limonada_indulcita()
  46. {
  47.     if(lamai == 0)
  48.     {
  49.         cout<<"Ingrediente lipsta!\n";
  50.         cout<<"Suma incasata este: "<<suma<<" lei\n";
  51.         exit(0);
  52.     }
  53.     else if(zahar <= 1)
  54.     {
  55.         cout<<"Ingrediente lipsta!\n";
  56.         cout<<"Suma incasata este: "<<suma<<" lei\n";
  57.         cout<<"Incercati o limonada neindulcita!\n";
  58.     }
  59.     else
  60.     {
  61.         lamai -=1;
  62.         zahar -= 2;
  63.         suma +=3;
  64.         cout<<"`````````````````````````````````\n";
  65.         cout<<"Ai primit o limodata indulcita!\n";
  66.         cout<<"`````````````````````````````````\n";
  67.     }
  68.  
  69. }
  70.  
  71. void Lemon::afisare_ingrediente()
  72. {
  73.     cout<<"Mai sunt "<<lamai<<" lamai si "<<zahar<<" cuburi de zahar\n";
  74. }
  75.  
  76. void Lemon::suma_incasata(){
  77.     cout<<"S-au incasat "<<suma<<" lei"<<endl;
  78. }
  79. int main()
  80. {   int a,b;
  81.     Lemon limonada;
  82.     limonada.init(a, b);
  83.     int choice;
  84.     do
  85.     {
  86.         cout<<"--------------------------------------------\n";
  87.         cout<<"MENIU\n";
  88.         cout<<"1. Limonada indulcita;\n";
  89.         cout<<"2. Limonada neindulcita;\n";
  90.         cout<<"3. Total incasari;\n";
  91.         cout<<"4. Iesire.\n\n";
  92.         cout<<"--------------------------------------------\n";
  93.         limonada.afisare_ingrediente();
  94.         cin>>choice;
  95.         cout<<"-------------------------------------------\n";
  96.         switch(choice)
  97.         {
  98.         case 1:
  99.             limonada.limonada_indulcita();
  100.             break;
  101.         case 2:
  102.             limonada.limonada_neindulcita();
  103.             break;
  104.         case 3:
  105.             cout<<"`````````````````````````````````\n";
  106.             limonada.suma_incasata();
  107.             cout<<"`````````````````````````````````\n";
  108.             break;
  109.         case 4:
  110.             exit(0);
  111.         default:
  112.             cout<<" Alegeti una dintre optiunile mentionate!\n";
  113.         }
  114.     }
  115.     while(choice != 4);
  116.     return 0;
  117. }
  118.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement