Advertisement
Guest User

Zicani Ins Test1

a guest
May 20th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. //Vasiot kod ovde:
  2. #include <iostream>
  3. #include <cstring>
  4. using namespace std;
  5. class ZicanInstrument
  6. {
  7. char ime[20];
  8. int brojzici;
  9. float cena;
  10. public:
  11. ZicanInstrument (){}
  12. ZicanInstrument (int brojzici1,float cena1,char *ime1)
  13. {
  14. brojzici=brojzici1;
  15. cena=cena1;
  16. strcpy (ime,ime1);
  17.  
  18. }
  19. ~ZicanInstrument(){}
  20. ZicanInstrument (const ZicanInstrument &t)
  21. {
  22. brojzici=t.brojzici;
  23. cena=t.cena;
  24. strcpy (ime,t.ime);
  25. }
  26. int GetZici(){return brojzici;}
  27. char *GetIme(){return ime;}
  28. float GetCena(){return cena;}
  29. void SetCena(float x){cena=x;}
  30. };
  31. class Mandolina : public ZicanInstrument {
  32. char forma[20];
  33. public:
  34. Mandolina (char *ime1,int brojzici1,float cena1,char *forma1): ZicanInstrument (brojzici1,cena1,ime1)
  35. {
  36. strcpy(forma,forma1);
  37. }
  38. ~Mandolina(){}
  39. Mandolina (const Mandolina &t) : ZicanInstrument (t)
  40. {
  41. strcpy(forma,t.forma);
  42. }
  43. bool operator== (Mandolina &t)
  44. {
  45. if (this->GetZici()==t.GetZici()) return 1;
  46. return 0;
  47. }
  48. float cena ()
  49. {
  50. if(strcmp (GetIme(),"Neapolitan")==0)
  51. {
  52. float x=GetCena();
  53. x=x+(x*15)/100;
  54. SetCena(x);
  55. return x;
  56. }
  57. return GetCena();
  58. }
  59. friend ostream &operator<< (ostream &out, Mandolina &t)
  60. {
  61. out<<t.forma<<" "<<t.GetIme()<<" "<<t.GetZici()<< " "<<t.GetCena();
  62. return out;
  63. }
  64. };
  65. class Violina : public ZicanInstrument
  66. {
  67. float golemina;
  68. public:
  69. Violina (float golemina1,int brojzici1,float cena1,char *ime1): ZicanInstrument (brojzici1,cena1,ime1)
  70. {
  71. golemina=golemina1;
  72. }
  73. Violina (const Violina &t): ZicanInstrument(t)
  74. {
  75. golemina = t.golemina;
  76. }
  77. ~Violina(){}
  78. bool operator==(Violina &t)
  79. {
  80. if (this->GetZici()==t.GetZici()) return 1;
  81. return 0;
  82. }
  83. friend ostream &operator<<(ostream &out,Violina &t)
  84. {
  85. out<<t.golemina<<" "<<t.GetIme()<<" "<<t.GetZici()<< " "<<t.GetCena();
  86. return out;
  87. }
  88. };
  89. int main() {
  90. char ime[20];
  91. int brojZici;
  92. float cena;
  93. char forma[20];
  94. cin >> ime >> brojZici >> cena >> forma;
  95. Mandolina m(ime, brojZici, cena, forma);
  96. int n;
  97. cin >> n;
  98. ZicanInstrument **zi = new ZicanInstrument*[2 * n];
  99. for(int i = 0; i < n; ++i) {
  100. cin >> ime >> brojZici >> cena >> forma;
  101. zi[i] = new Mandolina(ime, brojZici, cena, forma);
  102. }
  103. for(int i = 0; i < n; ++i) {
  104. float golemina;
  105. cin >> ime >> brojZici >> cena >> golemina;
  106. zi[n + i] = new Violina(ime, brojZici, cena, golemina);
  107. }
  108. pecatiInstrumenti(m, zi, 2 * n);
  109. for(int i = 0; i < 2 * n; ++i) {
  110. delete zi[i];
  111. }
  112. delete [] zi;
  113. return 0;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement