Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Produs {
  6. private:
  7. string denumireProdus;
  8. float pret;
  9. public:
  10. float getPret() {
  11. return pret;
  12. }
  13. Produs() {
  14. pret = 0;
  15. denumireProdus = "";
  16. }
  17. Produs(string denumire, float pret) {
  18. this->denumireProdus = denumire;
  19. this->pret = pret;
  20. }
  21.  
  22. };
  23.  
  24.  
  25.  
  26. class Angajat {
  27. private:
  28. string nume;
  29. float salariu;
  30. public:
  31. float getPret() {
  32. return salariu;
  33. }
  34. Angajat() {
  35. salariu = 0;
  36. nume = "";
  37. }
  38. Angajat(string nume, float salariu) {
  39. this->nume = nume;
  40. this->salariu = salariu;
  41. }
  42.  
  43. };
  44. class Magazin {
  45. private:
  46. const int cod;
  47. Produs* produse;
  48. int nrProduse;
  49. Angajat * * angajati;
  50. int nrAngajati;
  51.  
  52. static int contor;
  53. public:
  54. Magazin() :cod(contor++) {
  55. nrProduse = 0;
  56. nrAngajati = 0;
  57. produse = NULL;
  58. angajati = NULL;
  59.  
  60. }
  61. Magazin(int nrProduse, int nrAngajati, Produs* produse, Angajat**angajati) :cod(contor++) {
  62. this->nrAngajati = nrAngajati;
  63. this->nrProduse = nrProduse;
  64. if (produse != NULL) {
  65. this->produse = new Produs[nrProduse];
  66. for (int i = 0; i < nrProduse; i++) {
  67. this->produse[i] = produse[i];
  68. }
  69. }
  70.  
  71. if (angajati != NULL) {
  72. this->angajati = new Angajat*[nrAngajati];
  73. for (int i = 0; i < nrAngajati; i++) {
  74. this->angajati[i] = new Angajat(*angajati[i]);
  75. }
  76. }
  77. }
  78. ~Magazin() {
  79. if (this->produse != NULL) {
  80. delete[]this->produse;
  81.  
  82. }
  83. for (int i = 0; i < this->nrAngajati; i++) {
  84. if (this->angajati[i] != NULL) {
  85. delete this->
  86. }
  87. }
  88. }
  89. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement