generated from microverseinc/readme-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
person.rb
38 lines (31 loc) · 691 Bytes
/
person.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# person now inherits from nameable
require_relative './nameable'
class Person < Nameable
# getters and setters
attr_reader :id
attr_accessor :name, :age
# constructor
def initialize(age, name = 'Unknown', parent_permission = 'true')
super()
@id = Random.rand(1..1000)
@name = name
@age = age
@parent_permission = parent_permission
end
# private method that returns bolean
def of_age?
@age >= 18
end
private :of_age?
def correct_name
@name
end
def add_rental(rental)
@rental.push(rental)
rental.person = self
end
# private method that returns bolean
def can_use_services?
of_age? || @parent_permission
end
end