generated from microverseinc/readme-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
person.rb
40 lines (34 loc) · 830 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
39
40
# require Nemeable methoh
require_relative 'nameable'
require_relative 'rental'
# create a class called person
class Person < Nameable
attr_reader :id, :rentals
attr_accessor :name, :age, :parent_permission
# initialize the class person
def initialize(age, name = 'Unknown', parent_permission = true)
@id = rand(1..1000)
@name = name
@age = age
@parent_permission = parent_permission
@rentals = []
end
# Private method is_of_age?
def is_of_age?
@age >= 18
end
private :is_of_age?
# Public method can_use_services?
def can_use_services?
is_of_age? || @parent_permission
end
public :can_use_services?
# Public method correct_name
def correct_name
@name
end
# Public method add_rental
def add_rental(date, person)
Rental.new(date, person, self)
end
end