After months of insightful observation and analysis, I’ve come up with this php baby simulator.
- Class Baby extends Mom_and_Dad {
-
- public $status
-
- //[..]
-
- function check_status() {
-
- if( $this->status == "asleep") parent::enjoy_your_life_or_what_is_left()
-
- else $everything = true;
-
- if($everything) $this->cry();
-
- }
-
- function cry() {
-
-
- $volume = array('low', 'loud','louder','uber loud', "warn the sismologists it’s not an earthquake" )
-
- echo $volume[$index];
-
- }
-
- }
//Beware the loop
while($parents->still_love_each_other_enough()) {
$newborn = new Baby;
}
(maybe I should refactor it using cakephp or at least the MVC pattern: I’d really love to have a BabiesController)
Be careful: due to inherent hardware limitations, the constructor of the Baby class takes a lot to complete (more or less, 9 months). Once instantiated, the new baby object takes a lot of resources (parent’s hardware is used a lot). Oh, and it sucks, literally.
(no, it’s not my baby in the cover image)