<?php
header("Content-Type: text/plain; charset=utf-8");
?> 
<?php

error_reporting(-1);
mb_internal_encoding('utf-8');

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)
                if (is_object($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)
    {
        $ground = array();
        for ($i = 1; $i <= $n; $i++) {
            $ground[$i] = array_fill(1, $n, ' . ');
        }
        $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) {
                if (is_object($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++) {
        $animals = array();
        $x       = mt_rand(1, $z->length);
        $y       = mt_rand(1, $z->height);
        
        if (!is_object($z->ground[$y][$x])) {
            $animal            = new $type($x, $y);
            $animals[]         = $animal;
            $z->ground[$y][$x] = $animal;
        } else
            $i--;
    }
    for ($k = 1; $k <= $count2; $k++) {
        $animals = array();
        $x       = mt_rand(1, $z->length);
        $y       = mt_rand(1, $z->height);
        
        if (!is_object($z->ground[$y][$x])) {
            $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();
