Re: Beginner Tutorials for using CLASSES in PHP4

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

 



On Wed, 2007-10-10 at 14:44 +0100, Tony Marston wrote:
> ""Nathan Nobbe"" <quickshiftin@xxxxxxxxx> wrote in message 
> news:7dd2dc0b0710091950i62159761le400b3839677bebd@xxxxxxxxxxxxxxxxx
> > On 10/9/07, Robert Cummings <robert@xxxxxxxxxxxxx> wrote:
> >>
> >> On Tue, 2007-10-09 at 21:37 -0400, Nathan Nobbe wrote:
> >> >
> >> > does a lawn mower not have blades; and gas and a control panel; does it
> >> not
> >> > have
> >> > wheels?  my object modeling of a lawn mower would certainly have these
> >> > things;
> >> > and most likely i would mark components of the engine as private.
> >> > and what does a lawn mower cut anyway; grass; i thought that was it. 
> >> > so
> >> if
> >> > there
> >> > was no grass could there still be an algorithm to cut it?
> >> > i say grass is part of the grass-cutting algorithm.
> >>
> >> Well it helps to refine the algorithm, but let's say we use fingers
> >> instead as our measure... I'm sure we would find that we could cut grass
> >> also >:)
> >
> >
> > good point.
> > the lawn mower is still consistent of its own parts and they
> > comprise its implementation.
> >
> > -nathan
> 
> Yes, but a lawnmower does not contain grass, it is used to cut grass. Whole 
> grass goes in and cut grass comes out. The lawnmower does not have any grass 
> in its construction, therefore grass is not part of the implementation.

It may not be part of it's construction, but it certainly is a member
variable. It's along the lines of the following:

<?php

class Lawnmower
{
    var $works = true;
    var $grassyMulchCrapStuckToUndersideOfLawnmower = 0;

    function mow( $what )
    {
        if( !$this->works )
        {
            return false;
        }

        if( $what == 'grass' )
        {
            $this->grassyMulchCrapStuckToUndersideOfLawnmower +=
rand( 1, 100 );

            if( $this->grassyMulchCrapStuckToUndersideOfLawnmower >
1000 )
            {
                return $this->seize();
            }
        }
        else
        if( $what == 'fingers' )
        {
            // >:)
        }

        return true;
    }

    function seize()
    {
        return ($this->works = false);
    }
}

?>

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

-- 
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