Re: PHP Brain Teasers

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

 



Daniel Brown wrote:
>    What the hell?  Why not start a thread that can be fun and
> challenging for all of us.

One more before bed:

class pin
{
  private $mVisible;
  private $mInstantiateTime;

  public function __construct()
  {
    $this->mInstantiateTime = floor(time() / 86400) * 86400;
    $this->mVisible = rand() % 2;
  }

  public function isVisible()
  {
    return $this->mVisible;
  }

  public function pickup()
  {
    if ($this->mVisible)
    {
      $now = time();
      if (($now - $this->mInstantiateTime) < 86400)
        return 'Good Luck!';
    }
    return '';
  }
}

$pin = new pin();
if ($pin->isVisible())
  $have = $pin->pickup();

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