Advertisement
kalin729

hope this works somehow

Jun 19th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.41 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<vector>
  4. using namespace std;
  5. class Sladoled
  6. {
  7. private:
  8.     string vid;
  9.     int broi;
  10.     double cena;
  11. public:
  12.     Sladoled();
  13.     Sladoled (string, int, double);
  14.     void Read();
  15.     void Inf();
  16.     void Prodadeni(int x);
  17.     void Dobaveni(int x);
  18.     string GetVid();
  19.     int GetBroi();
  20.     double GetCena();
  21.     bool IsCena();
  22.     ~Sladoled();
  23. };
  24. Sladoled::Sladoled()
  25. {
  26.     vid="";
  27.     broi=0;
  28.     cena=0;
  29. };
  30. Sladoled::Sladoled(string vid1,int broi1, double cena1)
  31. {
  32.     vid=vid1;
  33.     broi=broi1;
  34.     cena=cena1;
  35. }
  36. Sladoled::~Sladoled()
  37. {
  38.  
  39. }
  40. void Sladoled::Read()
  41. {
  42.     cout<<"vid;";
  43.     cin.sync();
  44.     getline(cin,vid);
  45.     cout<<"Braoi:";
  46.     cin>>broi;
  47.     cout<<"Cena: ";
  48.     cin>>cena;
  49. }
  50. void Sladoled ::Inf()
  51. {
  52.     cout<<"vid;"<<vid<<endl;
  53.     cout<<"broi"<<broi<<endl;
  54.     cout<<"cena"<<cena<<endl;
  55. }
  56. void Sladoled::Prodadeni(int x)
  57. {
  58.     broi=broi-x;
  59. }
  60. void Sladoled::Dobaveni(int x)
  61. {
  62.     broi=broi+x;
  63. }
  64. string Sladoled::GetVid()
  65. {
  66.     return vid;
  67. }
  68. int Sladoled::GetBroi()
  69. {
  70.     return broi;
  71. }
  72. double Sladoled::GetCena()
  73. {
  74.     return cena;
  75. }
  76. bool Sladoled::IsCena()
  77. {
  78.     if (cena==0)
  79.         return true;
  80.     else
  81.     return false;
  82. }
  83.  
  84.  
  85. int main()
  86. {
  87.     char ch;
  88.     vector<Sladoled>a;
  89.     Sladoled r;
  90.     do
  91.     {
  92.         r.Read();
  93.         a.push_back(r);
  94.         cout<<"Prodyljete da ili ne:";
  95.         cin>>ch;
  96.     }
  97.     while(ch!='Y'&&ch!='y');
  98.     for(int i=0; i<a.size(); i++)
  99.     {
  100.     cout<<"Sladoled: "<<i+1<<endl;
  101.     a[i].Inf();
  102.     }
  103.     for(int i=0; i<a.size(); i++)
  104.     {
  105.      int y;
  106.      cout<<"Prodadeni baravinki:";
  107.      cin>>y;
  108.      if(a[i].GetVid()=="baravinki")
  109.      {
  110.      a[i].Prodadeni(y);
  111.      }
  112.     }
  113.     string n;
  114.     int add;
  115.     cout<<"n;";
  116.     cin.sync();
  117.     getline(cin,n);
  118.     cout<<"add:";
  119.     cin>>add;
  120.     for(int i=0; i<a.size(); i++)
  121.     {
  122.         if(a[i].GetVid()==n)
  123.         {
  124.           a[i].Dobaveni(add);
  125.         }
  126.     }
  127.     for(int i=0; i<a.size(); i++)
  128.     {
  129.     cout<<"Sladoled: "<<i+1<<endl;
  130.     a[i].Inf();
  131.     }
  132.         double min;
  133.     for (int i = 0; i <a.size(); i++)
  134.     {
  135.         min = a[0].GetCena();
  136.         if(a[i].GetCena()<min){min == a[i].GetCena();}
  137.     }
  138.     for (int i = 0; i <a.size(); i++)
  139.     {
  140.         if(a[i].GetCena()==min){
  141.                 cout << "Min: ";
  142.                 a[i].Inf();}
  143.     }
  144.  
  145. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement