type Taa = class Month, Day, Year: Integer; procedure SetValue (y: Integer); function LeapYear: Boolean; end;
type TForm1 = class(TForm) Button1: TButton; Label1: TLabel; EditYear: TEdit; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.DFM}
procedure Taa.SetValue (y: Integer); begin // Month := m; // Day := d; Year := y; end;
function Taa.LeapYear: Boolean; begin // call IsLeapYear in SysUtils.pas Result := IsLeapYear (Year); end;
procedure TForm1.Button1Click(Sender: TObject); var ADay: Taa; begin // create an object ADay := Taa.Create; try // use the object try ADay.SetValue (StrToInt (EditYear.Text)); if ADay.LeapYear then ShowMessage ('Leap year: ' + IntToStr (ADay.Year));
except on E: EConvertError do ShowMessage ('Wrong input'); end;
finally ADay.Free; // destroy the object end; end;