czlowiekzgon

gang cpp

Nov 28th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. #include "pch.h"
  2. #include "Gang.h"
  3.  
  4.  
  5.  
  6.  
  7.  
  8. Gang::Property::Property() {
  9.  
  10. }
  11.  
  12. Gang::Property::~Property() {
  13.  
  14. }
  15.  
  16. void Gang::Property::initProperty() {
  17. cout << "Podaj miasto w ktorym znajduje sie posiadlosc : ";
  18. cin >> city;
  19. cout << "Podaj ulice : ";
  20. cin >> street;
  21. cout << "Podaj wartosc posiadlosci : ";
  22. cin >> valueProperty;
  23. }
  24.  
  25. void Gang::Property::show()const {
  26. cout << "Miast : " << this->city << endl;
  27. cout << "Ulica : " << this->street << endl;
  28. cout << "Wartosc posiadlosci : " << this->valueProperty << endl;
  29.  
  30. }
  31.  
  32.  
  33. Gang::Money::Money() {
  34.  
  35. }
  36.  
  37. Gang::Money::~Money() {
  38.  
  39. }
  40.  
  41.  
  42. void Gang::Money::initMoney() {
  43. cout << "Podaj ilosc pieniedzy gangu : ";
  44. cin >> ammountMoney;
  45. }
  46.  
  47. void Gang::Money::show()const {
  48. cout << "Ilosc pieniedzy : " << this->ammountMoney << endl;
  49. }
  50.  
  51.  
  52.  
  53. Gang::Gang(){
  54. }
  55.  
  56.  
  57. Gang::~Gang(){
  58. }
  59.  
  60. void Gang::initGang() {
  61.  
  62. ptrBoss = new Boss;
  63.  
  64. ptrBoss->initBoss();
  65.  
  66. cout << "Podaj ilosc underbossow : ";
  67. cin >> sizeUndeboss;
  68. ptrUnderboss = new Underboss[sizeUndeboss];
  69. for (int i = 0; i < sizeUndeboss; i++) {
  70. ptrUnderboss[i].initUnderboss();
  71. }
  72.  
  73. cout << "Podaj ilosc posiadlosci : " << endl;
  74. cin >> sizeProperty;
  75.  
  76.  
  77. ptrProperty = new Property[sizeProperty];
  78. for (int i = 0; i < sizeProperty; i++) {
  79. ptrProperty[i].initProperty();
  80. }
  81. money.initMoney();
  82. }
  83. void remove(Assassin *&ptr, int &size, int where) {
  84.  
  85. }
  86.  
  87. void Gang::removeUnderboss(int where) {
  88.  
  89. if (sizeUndeboss == 0) {
  90. return;
  91. }
  92.  
  93. Underboss *supPtrUnderboss = new Underboss[sizeUndeboss - 1];
  94.  
  95. for (int i = 0; i < sizeUndeboss; i++) {
  96.  
  97. if (i < where) {
  98. supPtrUnderboss[i] = ptrUnderboss[i];
  99. }
  100. else if (i == where) {
  101.  
  102. }
  103. else {
  104. supPtrUnderboss[i - 1] = ptrUnderboss[i];
  105. }
  106. }
  107.  
  108.  
  109. delete[] ptrUnderboss;
  110. ptrUnderboss =supPtrUnderboss ;
  111. --sizeUndeboss;
  112.  
  113. }
  114.  
  115. //void Gang::addBoss(int where) {
  116. // Boss *sup_ptr = new Boss[sizeBoss + 1];
  117. //
  118. // for (int i = 0; i < sizeBoss + 1; i++) {
  119. //
  120. // if (i == where) {
  121. //
  122. // sup_ptr[i].initBoss();
  123. // }
  124. // else if (i > where) {
  125. // sup_ptr[i] = ptrBoss[i - 1];
  126. // }
  127. // else {
  128. // sup_ptr[i] = ptrBoss[i];
  129. // }
  130. //
  131. // }
  132. //
  133. //
  134. // delete[] ptrBoss;
  135. // ptrBoss = sup_ptr;
  136. // ++sizeBoss;
  137. //}
  138.  
  139. void Gang::show()const {
  140. cout << "Dane : " << endl;
  141. for (int i = 0; i < sizeProperty; i++) {
  142. ptrProperty[i].show();
  143. }
  144.  
  145. money.show();
  146.  
  147.  
  148. ptrBoss->show();
  149. for (int i = 0; i < sizeUndeboss; i++) {
  150. ptrUnderboss[i].show();
  151. }
  152.  
  153. }
  154.  
  155. void Gang::killBoss() {
  156. Consigliere *supPtrConsigliere = ptrBoss->getPtrConsigliere();
  157.  
  158. delete ptrBoss;
  159. ptrBoss =new Boss(ptrUnderboss[0], supPtrConsigliere);
  160. removeUnderboss(0);
  161.  
  162.  
  163. }
  164.  
  165.  
  166.  
  167. int Gang::getSizeBoss()const {
  168. return this->sizeBoss;
  169. }
  170.  
  171. Boss * Gang::getPtrBoss()const {
  172. return this->ptrBoss;
  173. }
  174.  
  175. Gang & Gang ::operator=(const Gang & g) {
  176.  
  177. ptrBoss = new Boss;
  178.  
  179. ptrBoss = g.ptrBoss;
  180.  
  181. return *this;
  182.  
  183. }
Add Comment
Please, Sign In to add comment