Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. class Citizen
  2. attr_reader :first_name
  3.  
  4. # DATA (instance variables)
  5. def initialize(first_name, last_name, age) # also called constructor in English
  6. @first_name = first_name # instance variable
  7. @last_name = last_name # instance variable
  8. @age = age # instance variable
  9. end
  10.  
  11. # BEHAVIOR (instance methods)
  12. def can_vote?
  13. return @age >= 18
  14. end
  15.  
  16. def full_name
  17. return "#{@first_name.capitalize} #{@last_name.capitalize}"
  18. end
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement