Ver Mensaje Individual
  #10 (permalink)  
Antiguo 30/11/2008, 05:30
Avatar de Italico76
Italico76
 
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años, 1 mes
Puntos: 292
De acuerdo Respuesta: Mi primer objeto - critiquen!!!

Acron_0248: wow, ahora si que fui desbordado con ese ejemplo que te trajistes

Muy complejo para mi je je / te agradezco un monton todo el tiempo que le me haz dedicado

Aca mi version "final" en la que incluyo la clase "IMG" que arma una imagen, la cual es usada para hacer los enlaces graficos:

Código PHP:
<?

class img {  // clase img 
  
private $url
  private 
$alt
  private 
$border;    
  
  function 
__construct($url){ 
   
$this->url=$url;   
   
self::set_border(0);
  } 
  
  function 
add_alt($alt){
   
$this->alt="alt='$alt'";
  }  
  
 function 
set_border($border){
   
$this->border="border='$border'";
 } 

  function 
dame_img(){
   return 
$this->img;
 } 

 function 
dame_alt(){
   return 
$this->alt;
 } 
 
 function 
show (){
  return 
"<img src='$this->url' $this->alt $this->border />";           
 }     


abstract class 
link // super-clase no-instanciable
  
protected $url;   
  protected 
$title
    
 function 
__construct($url){ 
   
$this->url=$url;        
 }     
  
 function 
add_title($title){
   
$this->title="title='$title'";
 }
 
 function 
dame_url(){
   return 
$this->url;
 } 
}

class 
link2text extends link{    // clase Link a texto
  
private $anchor
    
  function 
__construct($url,$anchor){ 
   
parent::__construct($url); 
   
$this->anchor $anchor
  } 

 function 
dame_anchor($anchor){
   return 
$this->anchor;
 }
   
 function 
show(){ 
   
$url=$this->url;
   
$anchor=$this->anchor;
   
$title=$this->title;        
   return 
"<a href='$url'  $title >$anchor </a>";
 } 
}

class 
link2graph extends link{  // clase Link a Grafico  
  
private $imagen;
    
  function 
__construct($url,$img_url){ 
   
parent::__construct($url);    
   
$this->imagen = new img($img_url);    
  }
  
  function 
add_alt($alt){
   
$this->imagen->add_alt($alt); // uso el metodo add_alt de la clase IMG
  
}  
    
 function 
show(){       
   
$img $this->imagen->show();    
   
$title=$this->title;        
 return 
"<a href='".$this->url."'  $title > $img </a>";
 }   
}

?>
__________________
Salu2!

Última edición por Italico76; 30/11/2008 a las 07:55