<?php
class World {
public $sideLength;
function __construct($sideLength) {
$this->sideLength = $sideLength;
}
function draw() {
foreach ($this->field as $line) {
echo "\n";
}
}
function place(Animal $animal) {
$x = mt_rand(1, $this->sideLength); $y = mt_rand(1, $this->sideLength);
$this->field[$x][$y] = $animal->icon;
}
}
abstract class Animal {
public $x;
public $y;
public $icon;
function __construct($icon) {
$this->icon = $icon;
}
}
class Mouse extends Animal {
public function move () {
}
}
$world1 = new World(8);
$mouse1 = new Mouse('1');
$world1->place($mouse1);
$world1->draw();
?>
PD9waHAKZXJyb3JfcmVwb3J0aW5nKC0xKTsKbWJfaW50ZXJuYWxfZW5jb2RpbmcoInV0Zi04Iik7CgpjbGFzcyBXb3JsZCB7CgkKCXB1YmxpYyAkc2lkZUxlbmd0aDsKCXB1YmxpYyAkZmllbGQgPSBhcnJheSgpOwoKCWZ1bmN0aW9uIF9fY29uc3RydWN0KCRzaWRlTGVuZ3RoKSB7CgkJJHRoaXMtPnNpZGVMZW5ndGggPSAkc2lkZUxlbmd0aDsKCQkkdGhpcy0+ZmllbGQgPSBhcnJheV9maWxsKDEsICRzaWRlTGVuZ3RoLCBhcnJheV9maWxsKDEsICRzaWRlTGVuZ3RoLCAiMCIpKTsJCQoJfQoKCWZ1bmN0aW9uIGRyYXcoKSB7CgkJZm9yZWFjaCAoJHRoaXMtPmZpZWxkIGFzICRsaW5lKSB7CgkJCWVjaG8gaW1wbG9kZSgiICAiLCRsaW5lKTsKCQkJZWNobyAiXG4iOwoJCX0KCX0KCglmdW5jdGlvbiBwbGFjZShBbmltYWwgJGFuaW1hbCkgewoJCSR4ID0gbXRfcmFuZCgxLCAkdGhpcy0+c2lkZUxlbmd0aCk7CgkJJHkgPSBtdF9yYW5kKDEsICR0aGlzLT5zaWRlTGVuZ3RoKTsKCgkJJHRoaXMtPmZpZWxkWyR4XVskeV0gPSAkYW5pbWFsLT5pY29uOwoJfQoKfQoKYWJzdHJhY3QgY2xhc3MgQW5pbWFsIHsKCXB1YmxpYyAk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