Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. #include "ApartElem.h"
  2. #include "string"
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. ApartElem::ApartElem()
  8. : adress("")
  9. , amount("0")
  10. , stage("0")
  11. , area("0")
  12. , Next(NULL)
  13. , IsWithBalcony(false)
  14. {
  15. }
  16.  
  17.  
  18. ApartElem::~ApartElem()
  19. {
  20. }
  21.  
  22. // Конструктор с параметрами
  23. ApartElem::ApartElem(string adress1, string amount1, string stage1, string area1, bool IsWithBalcony1)
  24. {
  25. adress = adress1;
  26. amount = amount1;
  27. stage = stage1;
  28. area = area1;
  29. IsWithBalcony = IsWithBalcony1;
  30. }
  31.  
  32.  
  33. // Конструктор копирования
  34. ApartElem::ApartElem(ApartElem& P1)
  35. {
  36. adress = P1.adress;
  37. amount = P1.amount;
  38. stage = P1.stage;
  39. area = P1.area;
  40. IsWithBalcony = P1.IsWithBalcony;
  41. }
  42.  
  43.  
  44. // Изменение всех параметров
  45. void ApartElem::SetAll(string adress1, string amount1, string stage1, string area1, bool IsWithBalcony1)
  46. {
  47. adress =adress1;
  48. amount = amount1;
  49. stage = stage1;
  50. area = area1;
  51. IsWithBalcony = IsWithBalcony1;
  52. }
  53.  
  54.  
  55. // Ввод с клавиатуры
  56. void ApartElem::Input()
  57. {
  58. cin.ignore();
  59. string tmp;
  60. cout << endl << "Введите адрес (ул,д,кв): ";
  61. getline(cin, tmp);
  62. adress = tmp;
  63.  
  64. cout << "Количество комнат: ";
  65. //cin.ignore();
  66. getline(cin, tmp);
  67. amount = tmp;
  68.  
  69. cout << "Этаж: ";
  70. //cin.ignore();
  71. getline(cin, tmp);
  72. stage = tmp;
  73.  
  74. cout << "Площадь (кв.м): ";
  75. //cin.ignore();
  76. getline(cin, tmp);
  77. area = tmp;
  78.  
  79. cout << "Наличие балкона(да/нет): ";
  80. //cin.ignore();
  81. while (true)
  82. {
  83. getline(cin, tmp);
  84. if ((tmp == "Да") || (tmp == "да"))
  85. {
  86. IsWithBalcony = true;
  87. break;
  88. }
  89. else if ((tmp == "Нет") || (tmp == "нет"))
  90. {
  91. IsWithBalcony = false;
  92. break;
  93. }
  94. else
  95. {
  96. cout << endl << "Введите 'да' или 'нет': ";
  97. continue;
  98. }
  99. }
  100. }
  101.  
  102.  
  103.  
  104. // Печать
  105. void ApartElem::Print()
  106. {
  107. cout << endl << "Адрес: " << adress << endl;
  108. cout << "Количетсво комнат: " << amount << endl;
  109. cout << "Этаж: " << stage << endl;
  110. cout << "Площадь: " << area << endl;
  111. if (IsWithBalcony)
  112. {
  113. cout << "Балкон: есть" << endl;
  114. }
  115. else
  116. {
  117. cout << "Балкон: отсутвует" << endl;
  118. }
  119. }
  120.  
  121. void ApartElem::SetNext(ApartElem* Next1)
  122. {
  123. Next = Next1;
  124. }
  125.  
  126.  
  127. ApartElem* ApartElem::GetNext()
  128. {
  129. return Next;
  130. }
  131.  
  132. string ApartElem::GetAdress()
  133. {
  134. return adress;
  135. }
  136.  
  137. string ApartElem::GetAmount()
  138. {
  139. return amount;
  140. }
  141.  
  142. string ApartElem::GetStage()
  143. {
  144. return stage;
  145. }
  146.  
  147. string ApartElem::GetArea()
  148. {
  149. return area;
  150. }
  151.  
  152. bool ApartElem::GetBalcony()
  153. {
  154. return IsWithBalcony;
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement