Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <cmath>
- using namespace std;
- class ZicanInstrument{
- protected:
- char ime[50];
- int brojZici;
- int cena;
- public:
- ZicanInstrument(char *ime="",int brojZici=0,int cena=0)
- {
- strcpy(this->ime,ime);
- this->brojZici=brojZici;
- this->cena=cena;
- }
- bool operator ==(ZicanInstrument &zi)
- {
- if(brojZici==zi.brojZici)return true;
- else return false;
- }
- friend ostream &operator<<(ostream &out,ZicanInstrument &z)
- {
- out<<z.ime<<" "<<z.brojZici<<" "<<z.cena;
- return out;
- }
- virtual int get_cena()
- {
- return cena;
- }
- virtual int get_brZici(){
- return brojZici;
- }
- };
- class Mandolina:public ZicanInstrument{
- private:
- char forma[20];
- public:
- Mandolina(char *ime="",int brojZici=0,int cena=0,char *forma="")
- :ZicanInstrument(ime,brojZici,cena)
- {
- strcpy(this->forma,forma);
- }
- int get_cena()
- {
- char test[20]={"Neapolitan"};
- if(strcmp(forma,test)==0)
- {
- return cena+(cena*0.15);
- }
- else return cena;
- }
- };
- class Violina:public ZicanInstrument{
- private:
- float golemina;
- public:
- Violina(char *ime="",int brojZici=0,int cena=0,float golemina=0)
- :ZicanInstrument(ime,brojZici,cena)
- {
- this->golemina=golemina;
- }
- int get_cena()
- {
- if(golemina==0.25)
- {
- return cena+(cena*0.10);
- }
- else if(golemina==1.00)
- {
- return cena+(cena*0.20);
- }
- else
- return cena;
- }
- };
- void pecatiInstrumenti(ZicanInstrument &zi,ZicanInstrument **x,int n)
- {
- for(int i=0;i<n;i++)
- if(zi == x[i])
- cout<<x[i]->cena()<<endl;
- }
- int main()
- {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement