Created
November 28, 2010 09:31
-
-
Save janmarek/718766 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// alt-shift zmena klavesnice EN->CS (QWERTY) | |
// ctrl-space code hints | |
// nekdo to spustte. nevime co to dela | |
namespace { | |
$users = array(); | |
$val = isset($_GET['lorem']) ? intval($_GET['lorem']) : 0; | |
} | |
namespace Posob\Borec\Na\Konec { | |
class User | |
{ | |
const MOCAK_SIZE = 10; | |
protected $name, $address, $promile, $bladderCapacity, $bladderFree = 2; | |
public function getCurrentAlcoholLevel() | |
{ | |
$rand = rand(1, 10); | |
return max(2, min(5, (int) ($this->promile * $rand))); | |
} | |
public function setAlcoholFree() | |
{ | |
throw new \LogicException("Vsichni jsme alkoholici!"); | |
} | |
public function setAlcoholLevel($lvl) | |
{ | |
$this->promile = floatval($lvl) / 100; | |
return $this; | |
} | |
public function drink(\Posob\Drink\IDrink $drink) | |
{ | |
if ($this->isMocakFull()) | |
throw new \Exception("Musis chcat"); | |
$this->promile += $drink->getAlcoholVolume(); | |
$this->blederCapacity += $drink->getDrinkVolume(); | |
} | |
public function isRadvis() | |
{ | |
if ($this->promile > 9999999) { | |
die; | |
} return false; | |
} | |
public function setAddress($address) | |
{ | |
$this->address = $address; | |
} | |
public function getAddress() | |
{ | |
return $this->address; | |
} | |
public function setName($name) | |
{ | |
$this->name = $name; | |
} | |
public function getName() | |
{ | |
return $this->name; | |
} | |
public function isMocakFull() | |
{ | |
return ($this->bladderCapacity >= self::MOCAK_SIZE); | |
} | |
public function isBladderFree() | |
{ | |
$tmp = $this->bladderFree--; | |
if ($this->bladderFree) { | |
$this->bladderFree = 2; | |
} | |
return $tmp <= 0 ? TRUE : FALSE; | |
} | |
} | |
} | |
namespace Posob\Food { } | |
namespace Posob\Drink { | |
interface IDrink | |
{ | |
public function getAlcoholVolume(); | |
public function getDrinkVolume(); | |
} | |
abstract class Beer implements IDrink | |
{ | |
public function getDrinkVolume() { | |
return 0.5; | |
} | |
public function getTaste() { | |
return true; | |
} | |
} | |
abstract class EuroBeer extends Beer | |
{ | |
public function getAlcoholVolume() | |
{ | |
return 0.04; | |
} | |
public function getTaste() { | |
throw new \NotImplementedException; | |
} | |
} | |
class Gambrinus extends EuroBeer | |
{ | |
} | |
class Plzen extends EuroBeer | |
{ | |
} | |
abstract class Nonalcoholic implements IDrink | |
{ | |
public function __construct() | |
{ | |
throw new \InvalidStateException("WTF?"); | |
} | |
public function getAlcoholVolume() | |
{ | |
return 0; | |
} | |
} | |
} | |
namespace { | |
use Posob\Borec\Na\Konec\User; | |
$users[] = $netteguru = new User(); | |
$users[] = $nettenovice = new User(); | |
for ($i = 0; $i < 25; ++$i) | |
$users[] = new User(); | |
for ($pocetdrinku = 0; $pocetdrinku < 200; ++$pocetdrinku) { | |
$pijeuser = $users[\rand(0, count($users) - 1)]; | |
echo 'Pije user ', $pijeuser->getName(), '!<br>'; | |
$pijeuser->drink(new \Posob\Drink\Plzen()); | |
} | |
zvladne: | |
for ($a = 0; $a < 20; $a++) { | |
$netteguru->setAlcoholLevel(0.5); | |
} | |
$nettenovice->setAlcoholLevel(rand(3, 50)); | |
if ($nettenovice->isRadvis()) { | |
$nettenovice->setName('i\'m TotAL LAma'); | |
} else { | |
$nettenovice->setName('i\'m Nett1st 1337 GuRu'); | |
} | |
if ($netteguru->isMocakFull() && !$netteguru->isMocakFull()) { | |
goto zvladne; | |
} | |
if ($netteguru->getCurrentAlcoholLevel() < $nettenovice->getCurrentAlcoholLevel()) | |
throw new \LogicException('?????'); | |
$netteRelease = new \DateTime('2004'); | |
foreach( $users as $uu ) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment