backlight0815

Untitled

Jun 16th, 2022
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. class Covid {
  2.  
  3. var population: Int
  4. var cases: Int
  5.  
  6. init(population :Int, cases: Int) {
  7. self.population = population
  8. self.cases = cases
  9. }
  10.  
  11. func infection(){
  12. cases -= 1
  13. }
  14.  
  15. func Recover(){
  16. cases += 1
  17. }
  18. func wasDeath() {
  19. population -= 1
  20. if population <= 0{
  21. print("The population are reducing")
  22. }
  23.  
  24. }
  25. }
  26.  
  27. class Doctor: Covid{
  28. let doctor: String
  29. var remainingPatient: Int
  30.  
  31. init(doctor: String, remainingPatient: Int, population: Int, cases: Int ){
  32. self.doctor = doctor
  33. self.remainingPatient = remainingPatient
  34. super.init(population :population, cases: cases)
  35.  
  36. }
  37.  
  38. func manpower(){
  39. if remainingPatient > 0 {
  40. remainingPatient -= 1
  41. } else{
  42. print("You have no enough of doctor")
  43. }
  44. }
  45. }
  46.  
  47. class Hospital: Doctor {
  48. var slots: Int
  49.  
  50. init(slots: Int, doctor: String, remainingPatient: Int, population: Int, cases: Int)
  51. {
  52. self.slots = slots
  53. super.init(doctor: doctor,remainingPatient: remainingPatient, population: population, cases: cases)
  54. }
  55.  
  56. override func wasDeath(){
  57. if slots > 0{
  58. slots -= 1
  59. } else {
  60. super.wasDeath()
  61. }
  62. }
  63. }
  64.  
  65. let Hospitals = Covid(population:12345,cases:1256)
  66.  
  67. let recover = Doctor(doctor:"First Line",remainingPatient:100,population:234,cases:98)
  68.  
  69. let Hospitalss = Hospital(slots:100, doctor:"RegencyHospital", remainingPatient:10, population:120, cases:10)
  70.  
  71. let Malaysia = Covid(population:100,cases:100)
  72.  
  73. let people = Malaysia
  74. print(Malaysia.population)
  75. print(people.population)
  76. people.infection()
  77. print(people.population)
  78. print(people.population)
Add Comment
Please, Sign In to add comment