Re: Re: Repetitive answers . . .

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 16, 2011 at 12:35 AM, tamouse mailing lists
>
> My baboon is offended.
>

class baboon extends human
{
   $ammo = '';

   public __construct($ammo)
   {
       $this->ammo = $ammo;
   }

   public function flingAt($target)
   {
       $target->flingAlert($this, $this->ammo);
   }

   public function flingAlert($source, $missile)
   {
       $hit = rand(0,1);
       if ($hit == 1)
       {
            $this->screech();
       }
       else {
            $this->howl();
       }

       // regardless, return the favor
       $this->flingAt($souce);
   }

   private function howl()
   {
        echo "Oooaa-oooaa";
   }

   private function screech()
   {
        echo "Eeeee";
   }
}

$ammo = "stuff";
$me = new baboon($ammo);
$you = new baboon($ammo);
$me->flingAt($you);

// :) This is pretty fun :)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux