-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewclass.rb
More file actions
49 lines (33 loc) · 766 Bytes
/
newclass.rb
File metadata and controls
49 lines (33 loc) · 766 Bytes
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
class Ferret
attr_accessor :name, :owner_name
def squeal
return "squeeeeee"
end
end
class Chincilla
attr_accessor :name,:owner_name
def squeek
return "eeeep"
end
end
class Parrot
attr_accessor :name, :owner_name
def tweet
return "Polly put the kettle on!"
end
end
my_ferret = Ferret.new
my_ferret.name= "Fredo"
ferretname = my_ferret.name
my_parrot = Parrot.new
my_parrot.name= "Budgie"
parrotname = my_parrot.name
my_chincilla = Chincilla.new
my_chincilla.name= "Dali"
chincillaname = my_chincilla.name
puts "#{ferretname} says #{my_ferret.squeal},
#{parrotname} says #{my_parrot.tweet},
and #{chincillaname} says #{my_chincilla.squeek}."
puts my_ferret.inspect
puts my_parrot.inspect
puts my_chincilla.inspect