Example #1
0
    {
        $this->tanque = 0;
    }
    public function llenarTanque($cant)
    {
        $this->tanque = $cant;
    }
    public function recorrer($km)
    {
        if ($this->estado) {
            $reducir = $km / 3;
            $this->tanque = $this->tanque - $reducir;
            if ($this->tanque <= 0) {
                $this->estado = false;
            }
        } else {
            echo "auto esta apagado";
        }
    }
}
$obj = new Deportivo();
$obj->llenarTanque(100);
$obj->encender();
$obj->recorrer(300);
$obj->estado();
$obj->llenarTanque(50);
$obj->encender();
$obj->estado();
?>