Dear, I am a bit confused with this PHP exercise.
Develop a Coffee class with attributes _Maximum capacity (the amount maximum coffee that the coffee machine can contain) and _quantityCurrent (the amount current coffee in the coffee maker).
Implement, at least, the following methods:
- Default Constructor: Sets the maximum capacity to 1000 (c.c.)
and the current one at zero (empty coffee maker). - fillCafe (): because that, makes the current amount equal to the capacity.
- serveTaza (int): simulates the action of serving a cup with the capacity indicated If the current amount of coffee "is not enough" to fill the cup, It serves what is left.
- emptyCafe (): sets the current coffee quantity to zero.
- addCafe (int): add the amount of coffee indicated to the coffee maker.
At the moment, what I have is this and but it gives me errors
<?php
class Cafetera {
public $capacidadMaxima;
public $CantidadActual;
public function __construct($capacidadMaxima,$CantidadActual)
{
$this->$capacidadMaxima = $capacidadMaxima;
$this->CantidadActual = $CantidadActual;
}
public function llenarCafetera()
{
$this->CantidadActual = capacidadMaxima;
}
public function servirTaza($LlenarTaza)
{
if($LlenarTaza > $this->CantidadActual) {
echo 'No alcanza para una taza. Recargá la cafetera!';
} else {
$this->CantidadActual -= $LlenarTaza;
}
}
public function vaciarCafetera()
{
$this->CantidadActual = 0;
}
public function agregarCafe($rellenar)
{
$this->CantidadActual = $rellenar;
}
public function Mostrar()
{
echo 'Capacidad Máxima: '. $capacidadMaxima.'<br>';
echo 'Capacidad Actual: '. $CantidadActual.'<br>';
}
}
$cafetera = new Cafetera(1000,0);
$cafetera->servirTaza(200);
$cafetera->agregarCafe(150);
$cafetera->mostrar();
?>