Ver Mensaje Individual
  #5 (permalink)  
Antiguo 10/02/2005, 15:50
Avatar de fabricioeche
fabricioeche
 
Fecha de Ingreso: enero-2003
Ubicación: Argentina
Mensajes: 126
Antigüedad: 22 años
Puntos: 1
Ya lo arreglé

Ya lo pude arreglar. Usé lo siguiente y quedó de primera:

Código:
class Cola{
	var $elem=array();
	var $cant;

	function crear(){
	$this->cant=0;
	}
	function vacia(){
	if ($this->cant==0)
		return true;
		else return false;
	}
	function insertar($x){
	$this->cant=$this->cant+1;
	/*$num=$this->cant;
	$this->elem[$num]=$x;
	*/
	array_push($this->elem,$x);

	}
	function suprimir(&$x){
	if ($this->vacia())
		echo "No existen elementos para suprimir<br>";
		else {$x=array_shift ($this->elem);
		$this->cant--;
		}
		
	}
	function mostrar(){
	//echo "Total:".array_count_values($this->elem);
	if ($this->vacia())
		echo "No existen elementos para mostrar<br>";
		else
		{
		for ($i=0;$i<$this->cant;$i++)
		{
			//echo $this->elem[$i]."<br>";
			foreach( $this->elem[$i] as $valor )
			   echo "Valor: $valor<br>\n";

		}//fin del for
		}
	}
}//fin del class
//$num=2;
$num=array(55,20,10);
$cola= new Cola;
$cola->crear();
for ($ii=0;$ii<3;$ii++)
{
$cola->insertar($num);
$num++;
}
echo "LISTO<br>";
$cola->mostrar();
echo "SUPRIMIR <BR>";
$cola->suprimir($m);
echo "Elem. Suprimido: $m <br>";
echo "MOSTRAR<br>";
$cola->mostrar();
Y me quedó como yo quería.
Gracias a todos por colaborar.
__________________
Fabro