-
Notifications
You must be signed in to change notification settings - Fork 0
/
fix_code_part2.rb
61 lines (44 loc) · 885 Bytes
/
fix_code_part2.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class Pet
def set_name= (name)
@name = name
end
def get_name
return @name
end
def set_owner=(owner_name)
@owner_name = owner_name
end
def get_owner
return @owner_name
end
end
class Ferret < Pet
def squeal
return "squeeeeee"
end
end
class Chinchilla < Pet
def squeek
return "eeeep"
end
end
class Parrot < Pet
def tweet
return "chirp"
end
end
my_ferret = Ferret.new
my_ferret.set_name= "Fredo"
ferretname = my_ferret.get_name
my_parrot = Parrot.new
my_parrot.set_name= "Budgie"
parrotname = my_parrot.get_name
my_chinchilla = Chinchilla.new
my_chinchilla.set_name= "Dali"
chinchillaname = my_chinchilla.get_name
puts "#{ferretname} says #{my_ferret.squeal},
#{parrotname} says #{my_parrot.tweet},
and #{chinchillaname} says #{my_chinchilla.squeek}."
puts my_ferret.inspect
puts my_parrot.inspect
puts my_chinchilla.inspect