1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
class Person
attr_accessor :name
def greeting
"Hello I'm #{@name}"
end
end
class Doctor < Person
attr_accessor :type
def specialty
"My specialty is in #{@type}"
end
end
person = Person.new
person.name = "Johnny"
puts person.greeting
doctor = Doctor.new
doctor.name = "John" doctor.type = "Family Doctor"
puts doctor.greeting puts doctor.specialty
|