Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Covid {
- var population: Int
- var cases: Int
- init(population :Int, cases: Int) {
- self.population = population
- self.cases = cases
- }
- func infection(){
- cases -= 1
- }
- func Recover(){
- cases += 1
- }
- func wasDeath() {
- population -= 1
- if population <= 0{
- print("The population are reducing")
- }
- }
- }
- class Doctor: Covid{
- let doctor: String
- var remainingPatient: Int
- init(doctor: String, remainingPatient: Int, population: Int, cases: Int ){
- self.doctor = doctor
- self.remainingPatient = remainingPatient
- super.init(population :population, cases: cases)
- }
- func manpower(){
- if remainingPatient > 0 {
- remainingPatient -= 1
- } else{
- print("You have no enough of doctor")
- }
- }
- }
- class Hospital: Doctor {
- var slots: Int
- init(slots: Int, doctor: String, remainingPatient: Int, population: Int, cases: Int)
- {
- self.slots = slots
- super.init(doctor: doctor,remainingPatient: remainingPatient, population: population, cases: cases)
- }
- override func wasDeath(){
- if slots > 0{
- slots -= 1
- } else {
- super.wasDeath()
- }
- }
- }
- let Hospitals = Covid(population:12345,cases:1256)
- let recover = Doctor(doctor:"First Line",remainingPatient:100,population:234,cases:98)
- let Hospitalss = Hospital(slots:100, doctor:"RegencyHospital", remainingPatient:10, population:120, cases:10)
- let Malaysia = Covid(population:100,cases:100)
- let people = Malaysia
- print(Malaysia.population)
- print(people.population)
- people.infection()
- print(people.population)
- print(people.population)
Add Comment
Please, Sign In to add comment