Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. template <class Item> class Wzor{
  6. static const int size = 6;
  7. Item Tab_[size];
  8. int counter_;
  9.  
  10. public:
  11. Wzor(){counter_ = 0;};
  12.  
  13.  
  14. Item addA(Item dodaj){
  15. if(counter_ <= 6){
  16. Tab_[counter_] = dodaj;
  17. counter_++;
  18. }
  19. }
  20.  
  21. Item deleteA(int usun){
  22. if(usun <= 6 && counter_ >= usun){
  23. Tab_[usun] = Tab_[counter_];
  24. counter_--;
  25. }
  26. }
  27. };
  28.  
  29. class Animal{
  30. string aName_;
  31. float aWeight_;
  32. int aBirth_;
  33. string aId_;
  34.  
  35. public:
  36. Animal(string aName, float aWeight, int aBirth, string aId) : aName_(aName), aWeight_(aWeight), aBirth_(aBirth), aId_(aId){};
  37.  
  38. Animal show(){
  39. cout << aName_ << " " << aWeight_ << " " << aBirth_ << " " << aId_ << " ";
  40. }
  41.  
  42. Animal operator = (Animal tottenham){
  43. aName_ = tottenham.aName_;
  44. aWeight_ = tottenham.aWeight_;
  45. aBirth_ = tottenham.aBirth_;
  46. aId_ = tottenham.aId_;
  47. }
  48. };
  49.  
  50. class Building{
  51. string bName_;
  52. float aGps_;
  53. float bGps_;
  54. float bHeight_;
  55.  
  56. public:
  57. Building(string bName, float aGps, float bGps, float bHeight) : bName_(bName), aGps_(aGps), bGps_(bGps), bHeight_(bHeight){};
  58.  
  59. Building show(){
  60. cout << bName_ << " " << aGps_ << " " << bGps_ << " " << bHeight_ << " ";
  61. }
  62.  
  63. Building operator = (Building tottenham){
  64. bName_ = tottenham.bName_;
  65. aGps_ = tottenham.aGps_;
  66. bGps_ = tottenham.bGps_;
  67. bHeight_ = tottenham.bHeight_;
  68. }
  69.  
  70.  
  71. };
  72. int main()
  73. {
  74. string Aname[6], Aid[6];
  75. float Aweight[6];
  76. int Abirth[6];
  77.  
  78. string Bname[6];
  79. float Bgps[6], Bbgps[6], Bheight[6];
  80.  
  81. bool liczba;
  82. for(int i = 0 ; i < 4; i++){
  83. string temp = Aname[i];
  84. string tmp = Bname[i];
  85. do{
  86. liczba = 1;
  87. cin >> temp;
  88. for(int j = 0; j < temp.size(); j++){
  89. if(static_cast<int> (temp[j]) == 32){
  90. liczba = 0;
  91. break;
  92. }
  93. }
  94. }while(liczba == 0);
  95.  
  96. Aname[i] = temp;
  97.  
  98. do{
  99. bool kropka = 1;
  100. liczba = 1;
  101. cin >>temp;
  102. for(int j = 0; j < temp.size(); j++){
  103. if(static_cast<int>(temp[j]) >= 48 and static_cast<int>(temp[j]) <= 57){
  104.  
  105.  
  106. }else if(static_cast<int> (temp[j]) == 46 and kropka == 0){
  107. kropka = 1;
  108. }else{
  109. liczba = 0;
  110. break;
  111. }
  112. }
  113. }while(liczba == 0);
  114. Aweight[i] = stof(temp);
  115. do{
  116. liczba = 1;
  117. cin >>temp;
  118. for(int j = 0; j < temp.size(); j++){
  119. if(static_cast<int>(temp[j]) >= 48 and static_cast<int>(temp[j]) <= 57){
  120. }
  121. }
  122. }while(liczba == 0);
  123. Abirth[i] = stoi(temp);
  124.  
  125. do{
  126. liczba = 1;
  127. cin >> temp;
  128. for(int j = 0; j < tmp.size(); j++){
  129. if(static_cast<int> (tmp[j]) == 32){
  130. liczba = 0;
  131. break;
  132. }
  133. }
  134. }while(liczba == 0);
  135.  
  136. Bname[i] = tmp;
  137.  
  138. do{
  139. bool kropka = 1;
  140. liczba = 1;
  141. cin >>tmp;
  142. for(int j = 0; j < tmp.size(); j++){
  143. if(static_cast<int>(tmp[j]) >= 48 and static_cast<int>(tmp[j]) <= 57){
  144.  
  145.  
  146. }else if(static_cast<int> (tmp[j]) == 46 and kropka == 0){
  147. kropka = 1;
  148. }else{
  149. liczba = 0;
  150. break;
  151. }
  152. }
  153. }while(liczba == 0);
  154. Bgps[i] = stof(tmp);
  155. do{
  156. bool kropka = 1;
  157. liczba = 1;
  158. cin >>tmp;
  159. for(int j = 0; j < tmp.size(); j++){
  160. if(static_cast<int>(tmp[j]) >= 48 and static_cast<int>(tmp[j]) <= 57){
  161.  
  162.  
  163. }else if(static_cast<int> (tmp[j]) == 46 and kropka == 0){
  164. kropka = 1;
  165. }else{
  166. liczba = 0;
  167. break;
  168. }
  169. }
  170. }while(liczba == 0);
  171. Bgps[i] = stof(tmp);
  172. do{
  173. bool kropka = 1;
  174. liczba = 1;
  175. cin >>tmp;
  176. for(int j = 0; j < tmp.size(); j++){
  177. if(static_cast<int>(tmp[j]) >= 48 and static_cast<int>(tmp[j]) <= 57){
  178.  
  179.  
  180. }else if(static_cast<int> (tmp[j]) == 46 and kropka == 0){
  181. kropka = 1;
  182. }else{
  183. liczba = 0;
  184. break;
  185. }
  186. }
  187. }while(liczba == 0);
  188. Bheight[i] = stof(tmp);
  189. }
  190.  
  191. Animal a1(Aname[0], Aweight[0], Abirth[0], Aid[0]);
  192. Animal a2(Aname[1], Aweight[1], Abirth[1], Aid[1]);
  193. Animal a3(Aname[2], Aweight[2], Abirth[2], Aid[2]);
  194. Animal a4(Aname[3], Aweight[3], Abirth[3], Aid[3]);
  195.  
  196.  
  197. Wzor<Animal> animalList;
  198. animalList.addA(a1);
  199. animalList.addA(a2);
  200. animalList.addA(a3);
  201. animalList.addA(a4);
  202.  
  203. Building b1(Bname[0], Bgps[0], Bbgps[0], Bheight[0]);
  204. Building b2(Bname[1], Bgps[1], Bbgps[1], Bheight[1]);
  205. Building b3(Bname[2], Bgps[2], Bbgps[2], Bheight[2]);
  206. Building b4(Bname[3], Bgps[3], Bbgps[3], Bheight[3]);
  207.  
  208. Wzor<Building> buildingList;
  209. buildingList.addA(b1);
  210. buildingList.addA(b2);
  211. buildingList.addA(b3);
  212. buildingList.addA(b4);
  213. return 0;
  214. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement