<?php
header ( "Content-Type: text/plain; charset=utf-8" ) ; ?>
<?php
abstract class Animal
{
public $x ;
public $y ;
public $icon ;
public $type ;
public $targetX ;
public $targetY ;
public function __construct( $x , $y )
{
$this -> x = $x ;
$this -> y = $y ;
foreach ( $z -> ground as $v ) {
foreach ( $v as $square )
$this -> targetX = abs ( $square -> x - $this -> x ) ; $this -> targetY = abs ( $square -> y - $this -> y ) ; }
}
}
}
class Cat extends Animal
{
public $type = 'cat' ;
public $icon = ' @ ' ;
public function getMoveCat( )
{
}
}
class Mouse extends Animal
{
public $type = 'mouse' ;
public $icon = ' 1 ' ;
}
class Table
{
public $length ;
public $height ;
public $cats ;
public $mouses ;
public $ground ;
public function __construct( $n , $cats , $mouses )
{
for ( $i = 1 ; $i <= $n ; $i ++ ) {
}
$this -> ground = $ground ;
$this -> length = $n ;
$this -> height = $n ;
$this -> cats = $cats ;
$this -> mouses = $mouses ;
}
public function FillTheGroundPls( )
{
$show = '' ;
foreach ( $this -> ground as $k => $v ) {
$table = '' ;
foreach ( $v as $key => $val ) {
$table .= $val ;
}
$show .= $table . "\n " ;
}
return $show ;
}
public function ShowMeTheGroundPls( )
{
foreach ( $this -> ground as $v ) {
foreach ( $v as $k => $val ) {
echo $val -> icon ;
} else {
echo ' . ' ;
}
}
echo "\n " ;
}
}
}
$z = new Table( 10 ) ;
function getNewAnimals( $type , $count , $type2 , $count2 )
{
global $z ;
for ( $i = 1 ; $i <= $count ; $i ++ ) {
$animal = new $type ( $x , $y ) ;
$animals [ ] = $animal ;
$z -> ground [ $y ] [ $x ] = $animal ;
} else
$i --;
}
for ( $k = 1 ; $k <= $count2 ; $k ++ ) {
$animal = new $type2 ( $x , $y ) ;
$animals [ ] = $animal ;
$z -> ground [ $y ] [ $x ] = $animal ;
} else
$i --;
}
return $z -> ground ;
}
$cat = 'Cat' ;
$mouse = 'Mouse' ;
$z -> ground = getNewAnimals( $mouse , 3 , $cat , 2 ) ;
$z -> showMeTheGroundPls ( ) ;
PD9waHA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gJzsKfQpjbGFzcyBUYWJsZQp7CiAgICBwdWJsaWMgJGxlbmd0aDsKICAgIHB1YmxpYyAkaGVpZ2h0OwogICAgcHVibGljICRjYXRzOwogICAgcHVibGljICRtb3VzZXM7CiAgICBwdWJsaWMgJGdyb3VuZDsKICAgIHB1YmxpYyBmdW5jdGlvbiBfX2NvbnN0cnVjdCgkbiwgJGNhdHMsICRtb3VzZXMpCiAgICB7CiAgICAgICAgJGdyb3VuZCA9IGFycmF5KCk7CiAgICAgICAgZm9yICgkaSA9IDE7ICRpIDw9ICRuOyAkaSsrKSB7CiAgICAgICAgICAgICRncm91bmRbJGldID0gYXJyYXlfZmlsbCgxLCAkbiwgJyAuICcpOwogICAgICAgIH0KICAgICAgICAkdGhpcy0+Z3JvdW5kID0gJGdyb3VuZDsKICAgICAgICAkdGhpcy0+bGVuZ3RoID0gJG47CiAgICAgICAgJHRoaXMtPmhlaWdodCA9ICRuOwogICAgICAgICR0aGlzLT5jYXRzICAgPSAkY2F0czsKICAgICAgICAkdGhpcy0+bW91c2VzID0gJG1vdXNlczsKICAgIH0KICAgIHB1YmxpYyBmdW5jdGlvbiBGaWxsVGhlR3JvdW5kUGxzKCkKICAgIHsKICAgICAgICAkc2hvdyA9ICcnOwogICAgICAgIAogICAgICAgIGZvcmVhY2ggKCR0aGlzLT5ncm91bmQgYXMgJGsgPT4gJHYpIHsKICAgICAgICAgICAgJHRhYmxlID0gJyc7CiAgICAgICAgICAgIGZvcmVhY2ggKCR2IGFzICRrZXkgPT4gJHZhbCkgewogICAgICAgICAgICAgICAgJHRhYmxlIC49ICR2YWw7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgJHNob3cgLj0gJHRhYmxlIC4gIlxuIjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuICRzaG93OwogICAgfQogICAgcHVibGljIGZ1bmN0aW9uIFNob3dNZVRoZUdyb3VuZFBscygpCiAgICB7CiAgICAgICAgZm9yZWFjaCAoJHRoaXMtPmdyb3VuZCBhcyAkdikgewogICAgICAgICAgICBmb3JlYWNoICgkdiBhcyAkayA9PiAkdmFsKSB7CiAgICAgICAgICAgICAgICBpZiAoaXNfb2JqZWN0KCR2YWwpKSB7CiAgICAgICAgICAgICAgICAgICAgZWNobyAkdmFsLT5pY29uOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICBlY2hvICcgLiAnOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGVjaG8gIlxuIjsKICAgICAgICB9CiAgICB9CiAgICAKICAgIAp9CgoKCiR6ID0gbmV3IFRhYmxlKDEwKTsKCmZ1bmN0aW9uIGdldE5ld0FuaW1hbHMoJHR5cGUsICRjb3VudCwgJHR5cGUyLCAkY291bnQyKQp7CiAgICBnbG9iYWwgJHo7CiAgICBmb3IgKCRpID0gMTsgJGkgPD0gJGNvdW50OyAkaSsrKSB7CiAgICAgICAgJGFuaW1hbHMgPSBhcnJheSgpOwogICAgICAgICR4ICAgICAgID0gbXRfcmFuZCgxLCAkei0+bGVuZ3RoKTsKICAgICAgICAkeSAgICAgICA9IG10X3JhbmQoMSwgJHotPmhlaWdodCk7CiAgICAgICAgCiAgICAgICAgaWYgKCFpc19vYmplY3QoJHotPmdyb3VuZFskeV1bJHhdKSkgewogICAgICAgICAgICAkYW5pbWFsICAgICAgICAgICAgPSBuZXcgJHR5cGUoJHgsICR5KTsKICAgICAgICAgICAgJGFuaW1hbHNbXSAgICAgICAgID0gJGFuaW1hbDsKICAgICAgICAgICAgJHotPmdyb3VuZFskeV1bJHhdID0gJGFuaW1hbDsKICAgICAgICB9IGVsc2UKICAgICAgICAgICAgJGktLTsKICAgIH0KICAgIGZvciAoJGsgPSAxOyAkayA8PSAkY291bnQyOyAkaysrKSB7CiAgICAgICAgJGFuaW1hbHMgPSBhcnJheSgpOwogICAgICAgICR4ICAgICAgID0gbXRfcmFuZCgxLCAkei0+bGVuZ3RoKTsKICAgICAgICAkeSAgICAgICA9IG10X3JhbmQoMSwgJHotPmhlaWdodCk7CiAgICAgICAgCiAgICAgICAgaWYgKCFpc19vYmplY3QoJHotPmdyb3VuZFskeV1bJHhdKSkgewogICAgICAgICAgICAkYW5pbWFsICAgICAgICAgICAgPSBuZXcgJHR5cGUyKCR4LCAkeSk7CiAgICAgICAgICAgICRhbmltYWxzW10gICAgICAgICA9ICRhbmltYWw7CiAgICAgICAgICAgICR6LT5ncm91bmRbJHldWyR4XSA9ICRhbmltYWw7CiAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICRpLS07CiAgICB9CiAgICAKICAgIHJldHVybiAkei0+Z3JvdW5kOwp9CgokY2F0ICAgPSAnQ2F0JzsKJG1vdXNlID0gJ01vdXNlJzsKCiR6LT5ncm91bmQgPSBnZXROZXdBbmltYWxzKCRtb3VzZSwgMywgJGNhdCwgMik7CiR6LT5zaG93TWVUaGVHcm91bmRQbHMoKTsK
stdout
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . @ .
1 . . . . . . . . .
. . . . . . . . . .
. . . . . . . . @ .
. . . . . . . . . .
. . . . . . . . 1 .
. . . . . . . . . .
. . . . . . . . 1 .
stderr
PHP Warning: Missing argument 2 for Table::__construct(), called in /home/WTRJtv/prog.php on line 96 and defined in /home/WTRJtv/prog.php on line 52
PHP Warning: Missing argument 3 for Table::__construct(), called in /home/WTRJtv/prog.php on line 96 and defined in /home/WTRJtv/prog.php on line 52
PHP Notice: Undefined variable: cats in /home/WTRJtv/prog.php on line 61
PHP Notice: Undefined variable: mouses in /home/WTRJtv/prog.php on line 62
PHP Notice: Undefined variable: z in /home/WTRJtv/prog.php on line 21
PHP Notice: Trying to get property of non-object in /home/WTRJtv/prog.php on line 21
PHP Warning: Invalid argument supplied for foreach() in /home/WTRJtv/prog.php on line 21
PHP Notice: Undefined variable: z in /home/WTRJtv/prog.php on line 21
PHP Notice: Trying to get property of non-object in /home/WTRJtv/prog.php on line 21
PHP Warning: Invalid argument supplied for foreach() in /home/WTRJtv/prog.php on line 21
PHP Notice: Undefined variable: z in /home/WTRJtv/prog.php on line 21
PHP Notice: Trying to get property of non-object in /home/WTRJtv/prog.php on line 21
PHP Warning: Invalid argument supplied for foreach() in /home/WTRJtv/prog.php on line 21
PHP Notice: Undefined variable: z in /home/WTRJtv/prog.php on line 21
PHP Notice: Trying to get property of non-object in /home/WTRJtv/prog.php on line 21
PHP Warning: Invalid argument supplied for foreach() in /home/WTRJtv/prog.php on line 21
PHP Notice: Undefined variable: z in /home/WTRJtv/prog.php on line 21
PHP Notice: Trying to get property of non-object in /home/WTRJtv/prog.php on line 21
PHP Warning: Invalid argument supplied for foreach() in /home/WTRJtv/prog.php on line 21