Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<vector>
- using namespace std;
- class Sladoled
- {
- private:
- string vid;
- int broi;
- double cena;
- public:
- Sladoled();
- Sladoled (string, int, double);
- void Read();
- void Inf();
- void Prodadeni(int x);
- void Dobaveni(int x);
- string GetVid();
- int GetBroi();
- double GetCena();
- bool IsCena();
- ~Sladoled();
- };
- Sladoled::Sladoled()
- {
- vid="";
- broi=0;
- cena=0;
- };
- Sladoled::Sladoled(string vid1,int broi1, double cena1)
- {
- vid=vid1;
- broi=broi1;
- cena=cena1;
- }
- Sladoled::~Sladoled()
- {
- }
- void Sladoled::Read()
- {
- cout<<"vid;";
- cin.sync();
- getline(cin,vid);
- cout<<"Braoi:";
- cin>>broi;
- cout<<"Cena: ";
- cin>>cena;
- }
- void Sladoled ::Inf()
- {
- cout<<"vid;"<<vid<<endl;
- cout<<"broi"<<broi<<endl;
- cout<<"cena"<<cena<<endl;
- }
- void Sladoled::Prodadeni(int x)
- {
- broi=broi-x;
- }
- void Sladoled::Dobaveni(int x)
- {
- broi=broi+x;
- }
- string Sladoled::GetVid()
- {
- return vid;
- }
- int Sladoled::GetBroi()
- {
- return broi;
- }
- double Sladoled::GetCena()
- {
- return cena;
- }
- bool Sladoled::IsCena()
- {
- if (cena==0)
- return true;
- else
- return false;
- }
- int main()
- {
- char ch;
- vector<Sladoled>a;
- Sladoled r;
- do
- {
- r.Read();
- a.push_back(r);
- cout<<"Prodyljete da ili ne:";
- cin>>ch;
- }
- while(ch!='Y'&&ch!='y');
- for(int i=0; i<a.size(); i++)
- {
- cout<<"Sladoled: "<<i+1<<endl;
- a[i].Inf();
- }
- for(int i=0; i<a.size(); i++)
- {
- int y;
- cout<<"Prodadeni baravinki:";
- cin>>y;
- if(а.getvid[i]=="baravinki")
- {
- a[i].Prodadeni(y);
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement