-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent.rb
More file actions
88 lines (66 loc) · 1.43 KB
/
student.rb
File metadata and controls
88 lines (66 loc) · 1.43 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require_relative 'person'
class Student < Person
attr_accessor :name, :age, :parent_permission
attr_reader :classroom
def initialize(classroom, age, name, parent_permission)
super(age, name, parent_permission)
@classroom = classroom
@id = Random.rand(1..1000)
end
def classroom=(classroom)
@classroom = classroom
classroom.students << self unless classroom.students.include?(self)
end
def student_id
@id
end
def student_id=(id)
@id = id
end
def can_use_services?
@parent_permission || of_age?
end
private
def of_age?
@age >= 18
end
def play_hookey
'¯\(ツ)/¯'
end
end
# require_relative 'person'
# class Student < Person
# def initialize(classroom, age, name, parent_permission)
# super(age, name, parent_permission)
# @classroom = classroom
# @id = Random.rand(1..1000)
# end
# attr_accessor :name, :age, :parent_permission
# attr_reader :classroom
# def classroom=(classroom)
# @classroom = classroom
# classroom.students << self unless classroom.students.include?(self)
# end
# def play_hookey
# '¯\(ツ)/¯'
# end
# def print_class
# @classroom
# end
# def student_id
# @id
# end
# def student_id=(id)
# @id = id
# end
# def can_use_services?
# @parent_permission || of_age?
# end
# private
# def of_age?
# @age >= 18
# end
# def play_hooky
# '¯(ツ)/¯'
# end
# end