Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Ambulance
  5. {
  6. public interface ISickness
  7. {
  8.  
  9. }
  10. public class PigV : ISickness
  11. {
  12.  
  13. }
  14. public class BirdV : ISickness
  15. {
  16.  
  17. }
  18. public class Cov19 : ISickness
  19. {
  20.  
  21. }
  22. interface IWard
  23. {
  24. int Maxpatient { set; get; }
  25. }
  26. public class PigW : IWard
  27. {
  28. public int Maxpatient { get; set; }
  29. public List<Patient> patientsPigV = new List<Patient>();
  30. }
  31.  
  32. public class BirdW : IWard
  33. {
  34. public int Maxpatient { get; set; }
  35. public List<Patient> patientsBirdV = new List<Patient>();
  36. }
  37. public class CoronaVirusW : IWard
  38. {
  39. public int Maxpatient { set; get; }
  40. public List<Patient> patientsCOV19 = new List<Patient>();
  41. }
  42.  
  43. public class Patient
  44. {
  45. public ISickness Sickness { get; set; }
  46. }
  47. class Hospital
  48. {
  49. PigW pigW = new PigW { Maxpatient = 3 };
  50. CoronaVirusW coronaVirusW = new CoronaVirusW { Maxpatient = 3 };
  51. BirdW birdW = new BirdW { Maxpatient = 3 };
  52. public List<Patient> Patients { get; set; } = new List<Patient>();
  53. public void Check()
  54. {
  55. foreach (Patient P in Patients)
  56. {
  57. if (P.Sickness == new Cov19())
  58. {
  59. if (coronaVirusW.Maxpatient > 0)
  60. {
  61. coronaVirusW.patientsCOV19.Add(P);
  62. coronaVirusW.Maxpatient--;
  63. }
  64. else
  65. {
  66. Console.WriteLine("Палата переполнена");
  67. }
  68. }
  69. if (P.Sickness == new BirdV())
  70. {
  71. if (birdW.Maxpatient > 0)
  72. {
  73. birdW.patientsBirdV.Add(P);
  74. birdW.Maxpatient--;
  75. }
  76. else
  77. {
  78. Console.WriteLine("Палата переполнена");
  79. }
  80. }
  81. if (P.Sickness == new PigV())
  82. {
  83. if (pigW.Maxpatient > 0)
  84. {
  85. pigW.patientsPigV.Add(P);
  86. pigW.Maxpatient--;
  87. }
  88. else
  89. {
  90. Console.WriteLine("Палата переполнена");
  91. }
  92. }
  93. }
  94. }
  95. }
  96.  
  97. class Program
  98. {
  99. static void Main(string[] args)
  100. {
  101. Hospital hospital = new Hospital();
  102. Patient P1 = new Patient { Sickness = new Cov19() };
  103. Patient P2 = new Patient { Sickness = new PigV() };
  104. Patient P3 = new Patient { Sickness = new BirdV() };
  105. Patient P4 = new Patient { Sickness = new BirdV() };
  106. Patient P5 = new Patient { Sickness = new BirdV() };
  107. Patient P6 = new Patient { Sickness = new BirdV() };
  108. Patient P7 = new Patient { Sickness = new BirdV() };
  109. Patient P8 = new Patient { Sickness = new BirdV() };
  110. Patient P9 = new Patient { Sickness = new BirdV() };
  111. hospital.Patients.Add(P1);
  112. hospital.Patients.Add(P2);
  113. hospital.Patients.Add(P3);
  114. hospital.Patients.Add(P4);
  115. hospital.Patients.Add(P5);
  116. hospital.Patients.Add(P6);
  117. hospital.Patients.Add(P7);
  118. hospital.Patients.Add(P8);
  119. hospital.Patients.Add(P9);
  120. hospital.Check();
  121. Console.ReadKey();
  122. }
  123. }
  124. }
  125.  
  126.  
  127. //List<IWard> Wards = new List<IWard> { new BirdW { Maxpatient = 5 }, new PigW { Maxpatient = 5 }, new CoronaVirusW { Maxpatient = 5 } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement