Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions solutionPill/animal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

interface AliveAnimal
{
public function breath();
public function move();
}

class Animal implements AliveAnimal
{
protected $age;
protected $fur;
protected $vertebrates;
protected $type;

public function __construct(int $age, bool $fur, bool $vertebrates, string $type)
{
$this->age = $age;
$this->fur = $fur;
$this->vertebrates = $vertebrates;
$this->type = $type;
}

public function breath()
{
echo 'i can breath';
}

public function move()
{
echo 'i can move';
}

public function sound()
{
echo 'i can make a sound';
}

public function getAge()
{
return $this->age;
}



public function __destruct()
{
}
}
34 changes: 34 additions & 0 deletions solutionPill/cat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
include_once './animal.php';

class Cat extends Animal
{
private $breed;

public function __construct(int $age, bool $fur, bool $vertebrates, string $type, string $breed)
{
parent::__construct($age, $fur, $vertebrates, $type);
$this->breed = $breed;
$this->age = $age * 7;
}

public function purr()
{
echo 'i can purr';
}

public function sound()
{
echo ' i can meow';
}
}

abstract class Feline
{
private $whiskerType;

public function throwObjectInstance()
{
return get_object_vars($this);
}
}
10 changes: 10 additions & 0 deletions solutionPill/run.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
include_once './cat.php';
include_once './animal.php';


$cat1 = new Cat(2, true, true, 'mammal', 4);

$animal1 = new Animal(2, true, true, 'mammal');

var_dump($animal1);
26 changes: 26 additions & 0 deletions solutions/human.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
include_once "./mammal.php";

class Human extends Mammal
{
private static $carrer;
private $salary;


public function __construct($name, $age, $sound, $numberOfChilds, $salary, $planet, $enviroment)
{
parent::__construct($name, $age, $sound, $numberOfChilds, $planet, $enviroment);
$this->salary = $salary;
}

public function getCarrer()
{
return $this->carrer;
}

public function getNumberOfChilds()
{
$childs = parent::getNumberOfChilds();
return 'number of childs ' . $childs;
}
}
38 changes: 38 additions & 0 deletions solutions/livingBeing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

<?php

interface Born
{
public function getPlanet();
public function getEnviroment();
}




abstract class LivingBeing implements Born
{
private $planet;
private $enviroment;

public function __construct($planet, $enviroment)
{
$this->planet = $planet;
$this->enviroment = $enviroment;
}

public function getEnviroment()
{
return $this->enviroment;
}

public function getPlanet()
{
return $this->planet;
}

public function __destruct()
{
echo "destruct living being";
}
}
46 changes: 46 additions & 0 deletions solutions/mammal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

include_once './livingBeing.php';

class Mammal extends LivingBeing
{
private $name;
private $age;
private $sound;
private $numberOfChilds;

public function __construct($name, $age, $sound, $numberOfChilds, $planet, $enviroment)
{
parent::__construct($planet, $enviroment);

$this->name = $name;
$this->age = $age;
$this->sound = $sound;
$this->numberOfChilds = $numberOfChilds;
}

public function getName()
{
return $this->name;
}

public function getAge()
{
return $this->age;
}

public function getSound()
{
return $this->sound;
}

public function getNumberOfChilds()
{
return $this->numberOfChilds;
}


public function __destruct()
{
}
};
12 changes: 12 additions & 0 deletions solutions/run.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

include_once './human.php';


$mammo1 = new Mammal('girafa', 28, 'ufff', 1, 'earth', 'terrestre');




$human1 = new Human('robert', 28, 'hello', 1, 5000, 'planet', 'terrestre');
$human2 = new Human('julio', 28, 'hello', 1, 5000, 'planet', 'terrestre');