fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9. class ResidenceType
  10. {
  11. static void Main(string[] args)
  12. {
  13. Residence[] houses = new Residence[]
  14. {
  15. new Residence(5, 5, 10, 125000000, "Особняк", 1, 1)
  16. };
  17.  
  18. foreach (Residence house in houses)
  19. Console.WriteLine(house.ToString());
  20. Console.ReadKey();
  21. }
  22. }
  23.  
  24. class Residence
  25. {
  26.  
  27. public int porchCount;
  28. public int floorCount;
  29. private int roomsOnFloor;
  30. private double meterCost;
  31. public string type;
  32. public int garage;
  33. public int garden;
  34.  
  35.  
  36. public int Porchs
  37. {
  38. get { return porchCount; }
  39. set { porchCount = value; }
  40. }
  41.  
  42. public int Floors
  43. {
  44. get { return floorCount; }
  45. set { floorCount = value; }
  46. }
  47.  
  48. public int RoomsOnFloor
  49. {
  50. get { return roomsOnFloor; }
  51. set { roomsOnFloor = value; }
  52. }
  53.  
  54. public double Cost
  55. {
  56. get { return meterCost; }
  57. set { meterCost = value; }
  58. }
  59.  
  60. public string Type
  61. {
  62. get { return type; }
  63. set { type = value; }
  64. }
  65.  
  66. public int Garage
  67. {
  68. get { return garage; }
  69. set { garage = value; }
  70. }
  71.  
  72. public int Garden
  73. {
  74. get { return garden; }
  75. set { garden = value; }
  76. }
  77.  
  78.  
  79. public Residence()
  80. {
  81. }
  82.  
  83. public Residence(int porchCount, int floorCount, int roomsOnFloor, double cost, string type, int garage, int garden)
  84. {
  85. this.porchCount = porchCount;
  86. this.floorCount = floorCount;
  87. this.roomsOnFloor = roomsOnFloor;
  88. this.meterCost = cost;
  89. this.type = type;
  90. this.garage = garage;
  91. this.garden = garden;
  92. }
  93.  
  94.  
  95. public int GetRoomsCountInPorch()
  96. {
  97. return roomsOnFloor * floorCount;
  98. }
  99.  
  100. public int GetRoomsCountInHouse()
  101. {
  102. return GetRoomsCountInPorch() * porchCount;
  103. }
  104.  
  105. public double HouseCost()
  106. {
  107. return (double)GetRoomsCountInHouse() * Cost;
  108. }
  109.  
  110. public double TheCostOfMaintainingTheGarden()
  111. {
  112. return (double)Garden;
  113. }
  114.  
  115.  
  116. public override string ToString()
  117. {
  118. return string.Format("Количество этажей: {0} \nКоличество подъездов: {1} \nКоличество комнат: {2} \nЖилье куплено за: {3} \nТип жилья: {4} \nГараж: {5} \nСад: {6} \nСтоимость жилья: {7} \nЗатраты на содержание сада: {8} ", Floors, Porchs, RoomsOnFloor, Cost, Type, Garage, Garden, HouseCost(), TheCostOfMaintainingTheGarden());
  119. }
  120. }
  121. }
Success #stdin #stdout 0.02s 14944KB
stdin
Standard input is empty
stdout
Количество этажей: 5 
Количество подъездов: 5 
Количество комнат: 10 
Жилье куплено за: 125000000 
Тип жилья: Особняк 
Гараж: 1 
Сад: 1 
Стоимость жилья: 31250000000 
Затраты на содержание сада: 1