Advertisement
LegoDrifter

Untitled

May 16th, 2020
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. class ZicanInstrument{
  8. protected:
  9.     char ime[50];
  10.     int brojZici;
  11.     int cena;
  12. public:
  13.     ZicanInstrument(char *ime="",int brojZici=0,int cena=0)
  14.     {
  15.         strcpy(this->ime,ime);
  16.         this->brojZici=brojZici;
  17.         this->cena=cena;
  18.     }
  19.     bool operator ==(ZicanInstrument &zi)
  20.     {
  21.         if(brojZici==zi.brojZici)return true;
  22.         else return false;
  23.     }
  24.     friend ostream &operator<<(ostream &out,ZicanInstrument &z)
  25.     {
  26.         out<<z.ime<<" "<<z.brojZici<<" "<<z.cena;
  27.         return out;
  28.     }
  29.     virtual int get_cena()
  30.     {
  31.         return cena;
  32.     }
  33.     virtual int get_brZici(){
  34.         return brojZici;
  35.     }
  36. };
  37. class Mandolina:public ZicanInstrument{
  38. private:
  39.     char forma[20];
  40. public:
  41.     Mandolina(char *ime="",int brojZici=0,int cena=0,char *forma="")
  42.                 :ZicanInstrument(ime,brojZici,cena)
  43.     {
  44.         strcpy(this->forma,forma);
  45.     }
  46.     int get_cena()
  47.     {
  48.         char test[20]={"Neapolitan"};
  49.         if(strcmp(forma,test)==0)
  50.         {
  51.             return cena+(cena*0.15);
  52.         }
  53.         else return cena;
  54.     }
  55. };
  56. class Violina:public ZicanInstrument{
  57. private:
  58.     float golemina;
  59. public:
  60.     Violina(char *ime="",int brojZici=0,int cena=0,float golemina=0)
  61.     :ZicanInstrument(ime,brojZici,cena)
  62.     {
  63.         this->golemina=golemina;
  64.     }
  65.     int get_cena()
  66.     {
  67.  
  68.         if(golemina==0.25)
  69.         {
  70.             return cena+(cena*0.10);
  71.         }
  72.         else if(golemina==1.00)
  73.         {
  74.             return cena+(cena*0.20);
  75.         }
  76.         else
  77.             return cena;
  78.     }
  79.  
  80. };
  81. void pecatiInstrumenti(ZicanInstrument &zi,ZicanInstrument **x,int n)
  82. {
  83.    for(int i=0;i<n;i++)
  84.     if(zi == x[i])
  85.     cout<<x[i]->cena()<<endl;
  86. }
  87.  
  88.  
  89.  
  90.  
  91.  
  92. int main()
  93. {
  94.  
  95.  
  96.     return 0;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement