Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace::std;
  4.  
  5. enum Material
  6. {
  7. bawelna,
  8. welna,
  9. jedwab,
  10. poliester
  11. };
  12.  
  13. enum Kolor
  14. {
  15. bialy,
  16. czarny,
  17. czerwony
  18. };
  19.  
  20. enum Wzor
  21. {
  22. paski,
  23. kratki,
  24. grochy
  25. };
  26.  
  27. enum Rodzaj
  28. {
  29. spodnie,
  30. bluza,
  31. sukienka
  32. };
  33.  
  34.  
  35. class Ubranie
  36. {
  37. public:
  38. Material material;
  39. Kolor kolor;
  40. Wzor wzor;
  41. Rodzaj rodzaj;
  42.  
  43. Ubranie()
  44. {
  45. ilosc++;
  46. }
  47.  
  48. Ubranie(Material material, Kolor kolor, Wzor wzor, Rodzaj rodzaj)
  49. {
  50. this->material = material;
  51. this->kolor = kolor;
  52. this->wzor = wzor;
  53. this->rodzaj = rodzaj;
  54.  
  55. ilosc++;
  56. }
  57.  
  58. virtual ~Ubranie();
  59.  
  60. static void Ilosc()
  61. {
  62. cout << ilosc << endl;
  63. }
  64.  
  65. friend ostream& operator<<(ostream& os, Ubranie& temp)
  66. {
  67. os << "Material: " << temp.material << endl;
  68. os << "Kolor: " << temp.kolor << endl;
  69. os << "Wzor: " << temp.wzor << endl;
  70. os << "Rodzaj: " << temp.rodzaj << endl;
  71. return os;
  72. }
  73.  
  74. private:
  75. static int ilosc;
  76. };
  77.  
  78. Ubranie::~Ubranie()
  79. {
  80. ilosc--;
  81. }
  82.  
  83. int Ubranie::ilosc = 0;
  84.  
  85. class Spodnie : public Ubranie
  86. {
  87. public:
  88. int dlugosc;
  89. int obwod_w_pasie;
  90.  
  91. Spodnie();
  92.  
  93. Spodnie(Material material, Kolor kolor, Wzor wzor, int dlugosc, int obwod_w_pasie)
  94. {
  95. this->material = material;
  96. this->kolor = kolor;
  97. this->wzor = wzor;
  98. this->rodzaj = Rodzaj(spodnie);
  99. this->dlugosc = dlugosc;
  100. this->obwod_w_pasie = obwod_w_pasie;
  101. }
  102. };
  103.  
  104. class Sukienka : public Ubranie
  105. {
  106. public:
  107. int dlugosc;
  108. int obwod_w_klatce;
  109.  
  110. Sukienka(Material material, Kolor kolor, Wzor wzor, int dlugosc, int obwod_w_klatce)
  111. {
  112. this->material = material;
  113. this->kolor = kolor;
  114. this->wzor = wzor;
  115. this->rodzaj = Rodzaj(sukienka);
  116. this->dlugosc = dlugosc;
  117. this->obwod_w_klatce = obwod_w_klatce;
  118. }
  119. };
  120.  
  121. class Bluza : public Ubranie
  122. {
  123. public:
  124. int obwod_kolnierza;
  125. int dlugosc;
  126. int obwod_w_klatce;
  127.  
  128. Bluza(Material material, Kolor kolor, Wzor wzor, int obwod_kolnierza, int dlugosc, int obwod_w_klatce)
  129. {
  130. this->material = material;
  131. this->kolor = kolor;
  132. this->wzor = wzor;
  133. this->rodzaj = Rodzaj(bluza);
  134. this->obwod_kolnierza = obwod_kolnierza;
  135. this->dlugosc = dlugosc;
  136. this->obwod_w_klatce = obwod_w_klatce;
  137. }
  138. };
  139.  
  140. class Kuloty : public Spodnie
  141. {
  142. public:
  143.  
  144. friend ostream& operator<<(ostream& os, Kuloty& temp)
  145. {
  146. os << "Rodzaj spodni: " << "Kuloty" << endl;
  147. return os;
  148. }
  149. };
  150.  
  151. class Marchewy : public Spodnie
  152. {
  153. public:
  154.  
  155. friend ostream& operator<<(ostream& os, Marchewy& temp)
  156. {
  157. os << "Rodzaj spodni: " << "Marchewy" << endl;
  158. return os;
  159. }
  160. };
  161.  
  162. class Cygaretki : public Spodnie
  163. {
  164. public:
  165.  
  166. friend ostream& operator<<(ostream& os, Cygaretki& temp)
  167. {
  168. os << "Rodzaj spodni: " << "Cygaretki" << endl;
  169. return os;
  170. }
  171. };
  172.  
  173. class Szwedy : public Spodnie
  174. {
  175. public:
  176.  
  177. friend ostream& operator<<(ostream& os, Szwedy& temp)
  178. {
  179. os << "Rodzaj spodni: " << "Szwedy" << endl;
  180. return os;
  181. }
  182. };
  183.  
  184. class Jeansy : public Spodnie
  185. {
  186. public:
  187.  
  188. friend ostream& operator<<(ostream& os, Jeansy& temp)
  189. {
  190. os << "Rodzaj spodni: " << "Jeansy" << endl;
  191. return os;
  192. }
  193. };
  194. class Chinosy : public Spodnie
  195. {
  196. public:
  197.  
  198. friend ostream& operator<<(ostream& os, Chinosy& temp)
  199. {
  200. os << "Rodzaj spodni: " << "Chinosy" << endl;
  201. return os;
  202. }
  203. };
  204.  
  205.  
  206.  
  207. int main()
  208. {
  209. //Pola i metody statyczne zostały użyte dlatego, że są one powiązane z całą klasą a nie konkretnym obiektem danej klasy.
  210.  
  211. Ubranie temp(bawelna, bialy, paski, spodnie);
  212. Ubranie::Ilosc();
  213. //temp.~Ubranie();
  214. //Ubranie::Ilosc();
  215. //Ubranie temp(bawelna, bialy, paski, spodnie);
  216. cout << temp << endl;
  217. Spodnie temp_1(bawelna, bialy, paski, 5, 5);
  218. Ubranie::Ilosc();
  219.  
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement