Example #1
0
            print "El auto ya esta apagado<br>";
        }
    }
    public function vaciarTanque()
    {
        $this->tanque = 0;
    }
    public function llenarTanque($cant)
    {
        $this->tanque = $cant;
    }
    public function usar($km)
    {
        if ($this->estado) {
            $reducir = $km / 3;
            $this->tanque = $this->tanque - $reducir;
            if ($this->tanque <= 0) {
                $this->estado = false;
            }
        } else {
            print "El auto esta pagado y no se puede usar <br>";
        }
    }
}
$obj = new Deportivo();
//$obj->ver(); // Class Deportivo contains 4 abstract methods and must therefore be declared abstract or implement the remaining methods (gasolina::vaciarTanque, gasolina::llenarTanque, Auto::encender, ...)
$obj->llenarTanque(100);
$obj->encender();
$obj->usar(300);
//$obj->usar(20);
$obj->estado();
Example #2
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();
?>