Advertisement
kalin729

asd

Jun 19th, 2017 (edited)
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 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. int main()
  84. {
  85.     char ch;
  86.     vector<Sladoled>a;
  87.     Sladoled r;
  88.     do
  89.     {
  90.         r.Read();
  91.         a.push_back(r);
  92.         cout<<"Prodyljete da ili ne:";
  93.         cin>>ch;
  94.     }
  95.     while(ch!='Y'&&ch!='y');
  96.     for(int i=0; i<a.size(); i++)
  97.     {
  98.     cout<<"Sladoled: "<<i+1<<endl;
  99.     a[i].Inf();
  100.     }
  101.     for(int i=0; i<a.size(); i++)
  102.     {
  103.      int y;
  104.      cout<<"Prodadeni baravinki:";
  105.      cin>>y;
  106.      if(а.getvid[i]=="baravinki")
  107.      {
  108.      a[i].Prodadeni(y);
  109.      }
  110.     }
  111. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement