-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdog.rb
41 lines (35 loc) · 905 Bytes
/
dog.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
#I am a naughty little doggy.
class Dog
def initialize(color, type)
@color, @type = color, type
@bones = []
end
def give(bone)
# ensuring that the dog has less than three bones in order to accept a new
# one
<<<<<<< HEAD
if @bones.length < 200
=======
if @bones.length < 83
>>>>>>> c6685e5e75c27a6473c8d0056ffca3f775b24060
# add the bone to the bones array
@bones << bone
else
puts "Too many bones!"
end
end
def eat
if @bones.length == 0
puts "There are no bones!"
else
# the pop method on the array will remove and return the last element
# in the array. In this case @bones.pop will give us back a "bone" object
# the "bone" object has a "size" attribute.
puts "I ate a #{@bones.pop.size} bone!"
end
end
#lskjfdas;lkdfjsd;lfjls;dkfj
def bad_dog
puts "Peed on the rug"
end
end