From 5923417fecc5da0d7135bb44ce5f010c8a870e40 Mon Sep 17 00:00:00 2001 From: Tammam Kbeili Date: Mon, 15 Jun 2015 13:09:17 -0700 Subject: [PATCH 1/6] add dog class --- dog.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 dog.rb diff --git a/dog.rb b/dog.rb new file mode 100644 index 0000000..0141015 --- /dev/null +++ b/dog.rb @@ -0,0 +1,30 @@ +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 + if @bones.length < 3 + # 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 + +end From 05d6c19b40fe11f5c1b8443cb94697a0d6d908be Mon Sep 17 00:00:00 2001 From: Tammam Kbeili Date: Mon, 15 Jun 2015 13:11:23 -0700 Subject: [PATCH 2/6] change the number of bones for the dog to 5 --- dog.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dog.rb b/dog.rb index 0141015..3e6a5e5 100644 --- a/dog.rb +++ b/dog.rb @@ -8,7 +8,7 @@ def initialize(color, type) def give(bone) # ensuring that the dog has less than three bones in order to accept a new # one - if @bones.length < 3 + if @bones.length < 5 # add the bone to the bones array @bones << bone else From 7525af33532c70ea53016323bb2e4d469b3c9b22 Mon Sep 17 00:00:00 2001 From: Tammam Kbeili Date: Mon, 15 Jun 2015 13:13:38 -0700 Subject: [PATCH 3/6] change the number of the dog bones to 6 --- dog.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dog.rb b/dog.rb index 0141015..e4de679 100644 --- a/dog.rb +++ b/dog.rb @@ -8,7 +8,7 @@ def initialize(color, type) def give(bone) # ensuring that the dog has less than three bones in order to accept a new # one - if @bones.length < 3 + if @bones.length < 6 # add the bone to the bones array @bones << bone else From 1c0e73197d794da420537e7a3aebed32c098e73f Mon Sep 17 00:00:00 2001 From: Tammam Kbeili Date: Mon, 15 Jun 2015 13:26:42 -0700 Subject: [PATCH 4/6] change the number of bones to 10 --- dog.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dog.rb b/dog.rb index 1bdd69b..a787685 100644 --- a/dog.rb +++ b/dog.rb @@ -8,7 +8,7 @@ def initialize(color, type) def give(bone) # ensuring that the dog has less than three bones in order to accept a new # one - if @bones.length < 7 + if @bones.length < 10 # add the bone to the bones array @bones << bone else From 94ad765f93caf5db6e0730b795cb2190aac05bcd Mon Sep 17 00:00:00 2001 From: Tammam Kbeili Date: Mon, 15 Jun 2015 13:25:00 -0700 Subject: [PATCH 5/6] change the number of bones to 8 --- dog.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dog.rb b/dog.rb index a787685..7f02d52 100644 --- a/dog.rb +++ b/dog.rb @@ -7,7 +7,7 @@ def initialize(color, type) def give(bone) # ensuring that the dog has less than three bones in order to accept a new - # one + # one if @bones.length < 10 # add the bone to the bones array @bones << bone From 0fe763e1704e4528d7b0a7fc92fa08347d2045db Mon Sep 17 00:00:00 2001 From: Tammam Kbeili Date: Mon, 15 Jun 2015 13:25:26 -0700 Subject: [PATCH 6/6] change the number of bones to 9 --- dog.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dog.rb b/dog.rb index 7f02d52..7013fdc 100644 --- a/dog.rb +++ b/dog.rb @@ -7,8 +7,8 @@ def initialize(color, type) def give(bone) # ensuring that the dog has less than three bones in order to accept a new - # one - if @bones.length < 10 + # one + if @bones.length < 9 # add the bone to the bones array @bones << bone else