Ver Mensaje Individual
  #14  
Antiguo 23-03-2008
Avatar de walito
walito walito is offline
Miembro
 
Registrado: jun 2005
Posts: 121
Reputación: 19
walito Va por buen camino
Si sabes usar record entonces no debe ser dificil.

Ejemplo de un record:
Código Delphi [-]
  TPersona = record
    edad: integer;
    nombre: string;            
    appelido: string;            
    direccion: string;
    telefono: string;
  end;

Ahora necesitarias un SETer y un GETer como para cargar y obtener datos.

Ejemplo de una clase.
Código Delphi [-]
unit MiClase;

interface

uses
  SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;

type  
  TPersona = record
    edad: integer;
    nombre: string;           
    apellido: string;           
    direccion: string;
    telefono: string;
  end;  
  
  TListaPersonas = array of TPersona;  
  
type
  TMiClase = class(TObject)
  private
    contPersonas: Integer;
    listaPersonas: TListaPersonas;
  public
    constructor Create;
    destructor Destroy; override;
    procedure AddPersona(const edad: Integer; const nombre, apellido, direccion, telefono: string);
    function GetPersona(const position: Integer);
    procedure DelPersona(const position: Integer);
  end;


implementation

{
******************************** TMiClase *********************************
}
constructor TMiClase.Create;
begin
    inherited Create;
end;

destructor TMiClase.Destroy;
begin
    inherited Destroy;
end;

procedure TMiClase.AddPersona(const edad: Integer; const nombre, apellido, direccion, telefono: string);
begin
    Inc(contPersonas);

    SetLength(listaPersonas, contPersonas);

    listaPersonas[High(listaPersonas)].edad := edad;
    listaPersonas[High(listaPersonas)].nombre := nombre;
    listaPersonas[High(listaPersonas)].apellido := apellido;
    listaPersonas[High(listaPersonas)].direccion := direccion;
    listaPersonas[High(listaPersonas)].telefono := telefono;
end;

function TMiClase.GetPersona(const position: Integer): TPersona;
begin
  if (position >= Low(listaPersonas)) and (position <= High(listaPersonas)) then
  begin
      Result := listaPersonas[position];
  end;
end;

procedure TMiClase.DelPersona(const position: Integer);
begin

end;

end.

Te dejo para vos el DelPersona.

Espero te sirba mi clase improvisada y pido perdon por algun errror.

Saludos
Responder Con Cita