Permalink
Browse files

Fix food() to accept arguments

  • Loading branch information...
1 parent 2a2a9f9 commit 9845356250b4cd20a41a50bdc4db55c8f9d46c5e @ehouse ehouse committed Jul 8, 2013
Showing with 13 additions and 2 deletions.
  1. +11 −2 lib/Acme/Meow.pm
  2. +2 −0 t/01-fun.t
View
@@ -15,13 +15,22 @@ class Acme::Meow {
}
#= feed our kitty
- method feed {
+ method feed($food?) {
if self.is_sleeping {
$!love += 0.25
} else {
$!love += 0.5
}
- say ~[self!kitty_status, ['crunch', 'lap lap', ''].pick]
+ if $food.defined {
+ if $food eq 'nip' {
+ say ~[self!kitty_status, 'crunch']
+ }
+ elsif $food eq 'milk' {
+ say ~[self!kitty_status, 'lap lap']
+ }
+ } else {
+ say ~[self!kitty_status, ['crunch', 'lap lap', ''].pick]
+ }
}
#= is our kitty sleeping?
View
@@ -8,6 +8,8 @@ ok $c.can('feed'), 'We can feed the cat';
ok $c.can('pet'), 'We can pet the cat';
lives_ok { $c.feed }, 'feeding works';
+lives_ok { $c.feed('nip') }, 'feeding nip works';
+lives_ok { $c.feed('milk') }, 'feeding milk works';
lives_ok { $c.pet }, 'petting works';
done;

0 comments on commit 9845356

Please sign in to comment.