Unit1.pas
资源名称:八数码问题的源代码.rar [点击查看]
上传用户:lhkj2008
上传日期:2010-01-04
资源大小:185k
文件大小:2k
源码类别:
其他智力游戏
开发平台:
Visual C++
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls,w_Case;
- type
- TForm1 = class(TForm)
- Button1: TButton;
- Memo1: TMemo;
- Button2: TButton;
- Button3: TButton;
- Button4: TButton;
- procedure FormCreate(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure Button3Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- private
- FCells: TWCells;
- procedure Move(Status:TWStatus);
- { Private declarations }
- public
- procedure Drawdisp;
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- FCells:=TWCells.Create(3,3);
- DrawDisp;
- end;
- procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- FCells.Free;
- end;
- procedure TForm1.Move(Status:TWStatus);
- begin
- // TODO -cMM: TForm1.Move default body inserted
- FCells.Move(Status);
- DrawDisp;
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- begin
- move(w_Case.Up)
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- Move(w_Case.Down);
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- Move(w_Case.Left);
- end;
- procedure TForm1.Button4Click(Sender: TObject);
- begin
- Move(w_Case.Right);
- end;
- procedure TForm1.Drawdisp;
- var
- intI,intJ:integer;
- strLine:string;
- begin
- // TODO -cMM: TForm1.Drawdisp default body inserted
- Memo1.Clear;
- for intI:=FCells.RowStart to FCells.RowEnd do
- begin
- strLine:='';
- for intJ :=FCells.ColStart to FCells.ColEnd do
- begin
- strLine:=strLine+'-'+inttostr(Fcells.Cells[inti,intJ].Center.Value);
- end;
- MeMo1.Lines.Add(copy(strLIne,2,length(strLine)));
- end;
- end;
- end.