Advertisement
Ozzypig

Doctor Class

May 10th, 2018
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.56 KB | None | 0 0
  1. local Person = require("Person") -- See: https://pastebin.com/DugLGsyg
  2. local Doctor = setmetatable({}, {__index = Person})
  3. Doctor.__index = Doctor
  4.  
  5. function Doctor.new(gender, name, field)
  6.     local self = setmetatable(Person.new(gender, name), Doctor)
  7.     self.field = field
  8.     return self
  9. end
  10.  
  11. function Doctor:greet()
  12.     self:speak("Hello, I am Dr. " .. self.name)
  13. end
  14.  
  15. function Doctor:heal(person)
  16.     person.health = person.health + 10
  17.     self:speak("Good thing you're not American or this would cost a fortune!")
  18.     person:speak("Gee, thanks!")
  19. end
  20.  
  21. return Doctor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement