Ver Mensaje Individual
  #11  
Antiguo 14-12-2005
[maeyanes] maeyanes is offline
Capo de los Capos
 
Registrado: may 2003
Ubicación: Campeche, México
Posts: 2.732
Reputación: 24
maeyanes Va por buen camino
No soy Román pero te contesto.

Si, si se puede hacer.

Aquí te pongo como sería tu clase padre usando solamente propiedades:

Código Delphi [-]
  TBiblioteca = class // Clase padre
  private
    FEditorial: string;
    FDir_Edit: string;
    FPer_Contac: string;
    FTlfno: string;
    FPoblacion: string;
    FProvincia: string;
  public
    constructor Create;
    destructor Destroy; override;

    // Propiedades de la clase
    property Editorial: string 
      read FEditorial
      write FEditorial;
    property Dir_Edit: string;
      read FDir_Edit
      write FDir_Edit;
    property Per_Contact: string
      read FPer_Contact
      write FPer_Contact;
    property Tlfno: string
      read FTlfno
      write FTlfno;
    property Poblacion: string
      read FPoblacion
      write FPoblacion;
    property Provincia: string
      read FProvincia
      write FProvincia;
  end;

Ahora, una clase descendiente de TBiblioteca podría ser así:

Código Delphi [-]
  TNovela = class(TBiblioteca) //Clase que hereda de Biblioteca
  private
    FAutor:string;
    FAno_Public:Integer;
    FNombre_Nov:string;
    FISBN:string;
  public
    constructor Create;
    destructor Destroy; override;

    // Propiedades de la clase
    property Autor: string
      read FAutor
      write FAutor;
    property Ano_Public: string
      read FAno_Public
      write FAno_Public;
    property Nombre: string
      read FNombre: string
      write FNombre;
    property ISBN: string
      read FISBN
      write FISBN;
  end;

Ahora, para darle valores a las propiedades de un objeto sería tan fácil como:

Código Delphi [-]
var
  Novela: TNovela;

begin
  Novela := TNovela.Create;
  Novela.Editorial := 'Editores Unidos'; // Esta propiedad es heredada
  Novela.Autor := 'Anónimo'; // Esta propiedad es exclusiva de TNovela
    // y sus descendientes.
end;

Espero que esto te aclare un poco el uso de las propiedades.



Saludos...
Responder Con Cita