Advertisement
czlowiekzgon

underboss

Nov 28th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. #include "pch.h"
  2. #include "Underboss.h"
  3.  
  4. using namespace std;
  5.  
  6. Underboss::Underboss(){
  7. }
  8.  
  9.  
  10. Underboss::~Underboss(){
  11. }
  12.  
  13.  
  14. void Underboss::initUnderboss() {
  15. cout << "Podaj nazwe underbossa : ";
  16. cin >> nameUnderboss;
  17. cout << "Podaj wiek underbossa : ";
  18. cin >> ageUnderboss;
  19. cout << "Podaj ilosc assassinow : ";
  20. cin >> sizeAssassin;
  21. ptrAssassin = new Assassin[sizeAssassin];
  22. for (int i = 0; i < sizeAssassin; i++) {
  23. ptrAssassin[i].initAssassin();
  24. }
  25.  
  26. cout << "Podaj ilosc dealerow : ";
  27. cin >> sizeDealer;
  28. ptrDealer = new Dealer[sizeDealer];
  29. for (int i = 0; i < sizeDealer; i++) {
  30. ptrDealer[i].initDealer();
  31. }
  32.  
  33.  
  34. }
  35.  
  36.  
  37. void Underboss::show()const {
  38. if (this == nullptr) {
  39. return;
  40. }
  41. cout << "Dane : ";
  42. cout << "Nazwa underbossa : " << this->nameUnderboss << endl;
  43. cout << "Wiek underbossa : " << this->ageUnderboss << endl;
  44. for (int i = 0; i < sizeAssassin; i++) {
  45. ptrAssassin[i].show();
  46. }
  47.  
  48. for (int i = 0; i < sizeDealer; i++) {
  49. ptrDealer->show();
  50. }
  51. }
  52.  
  53. string Underboss::getNameUnderboss()const {
  54. return this->nameUnderboss;
  55. }
  56. int Underboss::getAgeUnderboss()const {
  57. return this->ageUnderboss;
  58. }
  59.  
  60. int Underboss::getSizeAssassin()const {
  61. return this->sizeAssassin;
  62. }
  63. int Underboss::getSizeDealer()const {
  64. return this->sizeDealer;
  65. }
  66.  
  67. Assassin * Underboss::getPtrAssassin()const {
  68. return this->ptrAssassin;
  69. }
  70. Dealer * Underboss::getPtrDealer()const {
  71. return this->ptrDealer;
  72. }
  73.  
  74.  
  75. Underboss & Underboss::operator=(const Underboss & u) {
  76.  
  77. if (this == &u) {
  78. return *this;
  79. }
  80. nameUnderboss = u.nameUnderboss;
  81. ageUnderboss = u.ageUnderboss;
  82. sizeAssassin = u.sizeAssassin;
  83. sizeDealer = u.sizeDealer;
  84.  
  85. delete[] ptrAssassin;
  86. ptrAssassin = new Assassin[sizeAssassin];
  87.  
  88. for (int i = 0; i < sizeAssassin; i++) {
  89. ptrAssassin[i] = u.ptrAssassin[i];
  90. }
  91.  
  92. delete[] ptrDealer;
  93. for (int i = 0; i < sizeDealer; i++) {
  94. ptrDealer[i] = u.ptrDealer[i];
  95. }
  96.  
  97. return *this;
  98.  
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement