czlowiekzgon

Untitled

Nov 16th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #pragma once
  2. #include "pch.h"
  3. #include <iostream>
  4. #include <string>
  5. #include "Gang.h"
  6.  
  7. using namespace std;
  8.  
  9. Boss::Boss() {
  10.  
  11. }
  12.  
  13. void Boss::init() {
  14. cout << "Podaj nazwe Bossa";
  15. cin >> nameBoss;
  16. }
  17.  
  18. void Boss::show() {
  19. cout << "Nazwa Bossa : " << nameBoss << endl;
  20. }
  21.  
  22. Boss::~Boss() {
  23.  
  24. }
  25.  
  26. Gang::Gang()
  27. {
  28.  
  29. }
  30.  
  31. Gang::~Gang() {
  32. for (int i = 0; i < sizeBoss; i++) {
  33. ptrBoss[i].~Boss();
  34. }
  35. delete[]ptrBoss;
  36. }
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43. void Gang::init() {
  44.  
  45. cout << "podaj nazwe grupy : ";
  46. cin >> name_gang;
  47.  
  48.  
  49. cout << "podaj date zalozenia organizacji : ";
  50. string yr;
  51. cin >> yr;
  52. while (!atoi(yr.c_str()) && yr != "0") {
  53. cout << "podany rok nie jest liczba " << endl;
  54. cin >> yr;
  55. }
  56. year = atoi(yr.c_str());
  57.  
  58. cout << "Podaj liczbe Bossow" << endl;
  59. cin >> sizeBoss;
  60. ptrBoss = new Boss[sizeBoss];
  61. for (int i = 0; i < sizeBoss; i++) {
  62. ptrBoss[i].init();
  63. }
  64.  
  65. }
  66.  
  67.  
  68.  
  69.  
  70.  
  71. void Gang::show() {
  72. if (this != nullptr) {
  73. cout << "Nazwa organizacji : " << name_gang << endl;
  74. for (int i = 0; i < sizeBoss; i++) {
  75. ptrBoss[i].show();
  76. }
  77.  
  78. cout << "Rok zalozenia : " << year << endl;
  79. }
  80.  
  81. }
  82.  
  83. Gang & Gang :: operator=(const Gang & g) {
  84. name_gang = g.name_gang;
  85. year = g.year;
  86. sizeBoss = g.sizeBoss;
  87. ptrBoss = new Boss[sizeBoss];
  88. for (int i = 0; i < sizeBoss; i++) {
  89. ptrBoss[i] = g.ptrBoss[i];
  90. }
  91. return *this;
  92. }
Add Comment
Please, Sign In to add comment