-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpet.rb
More file actions
64 lines (50 loc) · 1.1 KB
/
pet.rb
File metadata and controls
64 lines (50 loc) · 1.1 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
class Pet
def set_name=(pet_name)
@name = pet_name
end
def get_name
return @name
end
def set_type=(pet_type)
@type = pet_type
end
def get_type
return @type
end
def set_owner=(owner_name)
@owner_name = owner_name
end
def get_owner
return @owner_name
end
def squeal
return "squeee"
end
def squeek
return "eeeep"
end
def tweet
return "chirp"
end
end
my_ferret = Pet.new
my_ferret.set_name = "Fredo"
my_ferret.set_type = "ferret"
ferretname = my_ferret.get_name
petferret = my_ferret.get_type
my_parrot = Pet.new
my_parrot.set_name = "Budgie"
my_parrot.set_type = "parrot"
parrotname = my_parrot.get_name
petparrot = my_parrot.get_type
my_chincilla = Pet.new
my_chincilla.set_name = "Dali"
my_chincilla.set_type = "chincilla"
chincillaname = my_chincilla.get_name
petchincilla = my_chincilla.get_type
puts "#{ferretname} the #{petferret} says #{my_ferret.squeal},
#{parrotname} the #{petparrot} says #{my_parrot.tweet},
and #{chincillaname} the #{petchincilla} says #{my_chincilla.squeek}."
puts my_ferret.inspect
puts my_parrot.inspect
puts my_chincilla.inspect