MeehoweCK

Untitled

May 28th, 2020
924
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.63 KB | None | 0 0
  1. // main.cpp
  2.  
  3. #include <iostream>
  4. #include <Firma.h>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     Firma firma(700);
  11.     firma.dodaj_klienta();
  12.     return 0;
  13. }
  14.  
  15. // Firma.h
  16.  
  17. #ifndef FIRMA_H
  18. #define FIRMA_H
  19.  
  20. #include "Mebel.h"
  21. #include "Klient.h"
  22. #include <vector>
  23.  
  24. using namespace std;
  25.  
  26. class Firma
  27. {
  28.     public:
  29.         Firma(double);
  30.         ~Firma();
  31.         void dodaj_klienta();
  32.         void dodaj_mebel();
  33.         void sprzedaj(Mebel*, Klient*, int);
  34.         int liczba_mebli();
  35.         int liczba_klientow();
  36.     private:
  37.         vector<Mebel*> meble;
  38.         vector<Klient*> klienci;
  39.         double kasa;
  40. };
  41.  
  42. #endif // FIRMA_H
  43.  
  44. // Firma.cpp
  45.  
  46. #include "Firma.h"
  47. #include <iostream>
  48.  
  49. using namespace std;
  50.  
  51. /*class Firma
  52. {
  53.     public:
  54.         Firma(double);
  55.         ~Firma();
  56.         void dodaj_klienta();
  57.         void dodaj_mebel();
  58.         void sprzedaj(Mebel*, Klient*, int);
  59.         int liczba_mebli();
  60.         int liczba_klientow();
  61.     private:
  62.         vector<Mebel*> meble;
  63.         vector<Klient*> klienci;
  64.         double kasa;
  65. };*/
  66.  
  67. Firma::Firma(double money) : kasa(money)
  68. {
  69. }
  70.  
  71. Firma::~Firma()
  72. {
  73.     for(unsigned i = 0; i < meble.size(); ++i)
  74.         delete meble[i];
  75.     for(unsigned i = 0; i < klienci.size(); ++i)
  76.         delete klienci[i];
  77. }
  78.  
  79. void Firma::dodaj_klienta()
  80. {
  81.     cout << "Podaj dane klienta (imie, nazwisko, nr telefonu): ";
  82.     string imie, nazwisko;
  83.     int numer;
  84.     cin >> imie >> nazwisko >> numer;
  85.     while(numer < 100000000 || numer > 999999999)
  86.     {
  87.         cout << "Wpisano nieprawidlowy numer telefonu, wpisz ponownie: ";
  88.         cin >> numer;
  89.     }
  90.     Klient* klient = new Klient(imie, nazwisko, numer);
  91.     klienci.push_back(klient);
  92. }
  93.  
  94. //void Firma::dodaj_mebel()
  95.  
  96. // Mebel.h
  97.  
  98. #ifndef MEBEL_H
  99. #define MEBEL_H
  100.  
  101. #include "../head.h"
  102. #include "Klient.h"
  103. #include <iostream>
  104.  
  105. using namespace std;
  106.  
  107. class Mebel
  108. {
  109.     public:
  110.         Mebel(double, double, double, typ_mebel, double, string, double, int);
  111.         void sprzedaj(Klient*);
  112.     private:
  113.         double wymiar_x;
  114.         double wymiar_y;
  115.         double wymiar_z;
  116.         typ_mebel mebel;
  117.         double masa;
  118.         string nazwa;
  119.         double cena;
  120.         int ilosc;
  121. };
  122.  
  123. #endif // MEBEL_H
  124.  
  125. // Mebel.cpp
  126.  
  127. #include "Mebel.h"
  128.  
  129. /*class Mebel
  130. {
  131.     public:
  132.         Mebel(double, double, double, typ_mebel, double, string, double, int);
  133.         void sprzedaj(Klient*);
  134.     private:
  135.         double wymiar_x;
  136.         double wymiar_y;
  137.         double wymiar_z;
  138.         typ_mebel mebel;
  139.         double masa;
  140.         string nazwa;
  141.         double cena;
  142.         int ilosc;
  143. };*/
  144.  
  145. Mebel::Mebel(double x, double y, double z, typ_mebel rodzaj, double waga, string name, double price, int ile) :
  146.     wymiar_x(x), wymiar_y(y), wymiar_z(z), mebel(rodzaj), masa(waga), nazwa(name), cena(price), ilosc(ile)
  147. {
  148. }
  149.  
  150. // head.h
  151.  
  152. #ifndef HEAD_H
  153. #define HEAD_H
  154.  
  155. class Firma;
  156. class Mebel;
  157. class Klient;
  158.  
  159. enum class typ_mebel
  160. {
  161.     lozko,
  162.     szafa
  163. };
  164.  
  165. #endif // HEAD_H
  166.  
  167. // Klient.h
  168.  
  169. #ifndef KLIENT_H
  170. #define KLIENT_H
  171.  
  172. #include "Mebel.h"
  173. #include "../head.h"
  174. #include <vector>
  175. #include <iostream>
  176.  
  177. using namespace std;
  178.  
  179. class Klient
  180. {
  181.     public:
  182.         Klient(string, string, int);
  183.         void zakup_mebla();
  184.     private:
  185.         string imie;
  186.         string nazwisko;
  187.         int numer_telefonu;
  188.         double wydatki;
  189.         vector<Mebel*> zakupione_meble;
  190. };
  191.  
  192. #endif // KLIENT_H
  193.  
  194. // Klient.cpp
  195.  
  196. #include "Klient.h"
  197.  
  198. /*class Klient
  199. {
  200.     public:
  201.         Klient(string, string, int);
  202.         void zakup_mebla();
  203.     private:
  204.         string imie;
  205.         string nazwisko;
  206.         int numer_telefonu;
  207.         double wydatki;
  208.         vector<Mebel*> zakupione_meble;
  209. };*/
  210.  
  211. Klient::Klient(string name, string scndname, int telefon) : imie(name), nazwisko(scndname), numer_telefonu(telefon)
  212. {
  213. }
  214.  
  215. // Lozko.h
  216.  
  217. #ifndef LOZKO_H
  218. #define LOZKO_H
  219.  
  220. #include "Mebel.h"
  221.  
  222. enum class typ_materac
  223. {
  224.     piankowy,
  225.     syntetyczny,
  226.     sprezynowy
  227. };
  228.  
  229. enum class typ_rama
  230. {
  231.     drewniana,
  232.     metalowa,
  233.     plyta
  234. };
  235.  
  236. class Lozko : public Mebel
  237. {
  238.     public:
  239.         Lozko();
  240.     private:
  241.         typ_materac materac;
  242.         typ_rama rama;
  243. };
  244.  
  245. #endif // LOZKO_H
  246.  
  247. // Lozko.cpp
  248.  
  249. #include "Lozko.h"
  250.  
  251. /*Lozko::Lozko()
  252. {
  253.     //ctor
  254. }
  255. */
  256.  
  257. // Szafa.h
  258.  
  259. #ifndef SZAFA_H
  260. #define SZAFA_H
  261.  
  262. #include "Mebel.h"
  263.  
  264. class Szafa : public Mebel
  265. {
  266.     public:
  267.         Szafa();
  268.     private:
  269.         bool lustro;
  270.         int liczba_polek;
  271. };
  272.  
  273. #endif // SZAFA_H
  274.  
  275. // Szafa.cpp
  276.  
  277. #include "Szafa.h"
  278.  
  279. /*Szafa::Szafa()
  280. {
  281.     //ctor
  282. }
  283. */
Advertisement
Add Comment
Please, Sign In to add comment