unit Dates1Form;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TDate = class
Month, Day, Year: Integer;
procedure SetValue (m, d, y: Integer);
function LeapYear: Boolean;
end;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
EditYear: TEdit;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
procedure TDate.SetValue (m, d, y: Integer);
begin
Month := m;
Day := d;
Year := y;
end;
function TDate.LeapYear: Boolean;
begin
Result := IsLeapYear (Year);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
ADay: TDate;
begin
ADay := TDate.Create;
ADay.SetValue (1, 1, StrToInt (EditYear.Text));
if ADay.LeapYear then
ShowMessage ('Leap year: ' + IntToStr (ADay.Year));
ADay.Free;
end;
end.
|