Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Person
- attr_reader :name
- attr_accessor :bank_account
- def initialize(name = "unknown")
- @name=name
- @bank_account = 25
- @happiness = 8
- @hygiene = 8
- end
- def clean?
- if @hygiene > 7
- return true
- else
- return false
- end
- end
- def happy?
- if @happiness > 7
- return true
- else
- return false
- end
- end
- def get_paid(salary)
- @bank_account += salary
- return "all about the benjamins"
- end
- def hygiene=(hygiene)
- if hygiene > 10
- @hygiene = 10
- elsif hygiene < 0
- @hygiene = 0
- else
- @hygiene = hygiene
- end
- end
- def hygiene
- @hygiene
- end
- def happiness=(happiness)
- if happiness > 10
- @happiness = 10
- elsif happiness < 0
- @happiness = 0
- else
- @happiness = happiness
- end
- end
- def happiness
- @happiness
- end
- def take_bath
- self.hygiene += 4
- return "♪ Rub-a-dub just relaxing in the tub ♫"
- end
- def work_out
- self.hygiene -= 3
- self.happiness += 2
- return "♪ another one bites the dust ♫"
- end
- def call_friend(friend)
- self.happiness += 3
- friend.happiness += 3
- return "Hi #{friend.name}! It's #{self.name}"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement