Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Citizen
- attr_reader :first_name
- # DATA (instance variables)
- def initialize(first_name, last_name, age) # also called constructor in English
- @first_name = first_name # instance variable
- @last_name = last_name # instance variable
- @age = age # instance variable
- end
- # BEHAVIOR (instance methods)
- def can_vote?
- return @age >= 18
- end
- def full_name
- return "#{@first_name.capitalize} #{@last_name.capitalize}"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement