1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149:
| unit Unit1;
{$mode objfpc}{$H+}
interface
uses Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; Edit2: TEdit; Label1: TLabel; a7: TLabel; b1: TLabel; b2: TLabel; b3: TLabel; b4: TLabel; b5: TLabel; b6: TLabel; b7: TLabel; c1: TLabel; c2: TLabel; Label2: TLabel; c3: TLabel; c4: TLabel; c5: TLabel; c6: TLabel; c7: TLabel; Label3: TLabel; a1: TLabel; a2: TLabel; a3: TLabel; a4: TLabel; a5: TLabel; a6: TLabel; Label4: TLabel; Label5: TLabel; ListBox1: TListBox; Panel1: TPanel; Panel2: TPanel; Panel3: TPanel; procedure Button1Click(Sender: TObject); private public end;
var Form1: TForm1; scheibe: array of string; belA, belB, belC, n, runde: integer;
implementation
procedure movetower (n: integer; afromfield, atofield, ausingfield: integer); begin if n > 1 then movetower (n - 1, afromfield, ausingfield, atofield);
form1.listbox1.items.add('-> Scheibe ' + inttostr(n) + ' von Feld ' + inttostr(afromfield) + ' nach Feld ' + inttostr(atofield)); inc(runde);
if afromfield = 1 then begin tlabel(form1.findcomponent('A' + inttostr(belA))).caption := 'II'; tlabel(form1.findcomponent('A' + inttostr(belA))).left := 104; dec(belA); end;
if afromfield = 2 then begin tlabel(form1.findcomponent('B' + inttostr(belB))).caption := 'II'; tlabel(form1.findcomponent('B' + inttostr(belB))).left := 104; dec(belB); end;
if afromfield = 3 then begin tlabel(form1.findcomponent('C' + inttostr(belC))).caption := 'II'; tlabel(form1.findcomponent('C' + inttostr(belC))).left := 104; dec(belC); end;
if atofield = 1 then begin inc(belA); tlabel(form1.findcomponent('A' + inttostr(belA))).caption := scheibe[n]; tlabel(form1.findcomponent('A' + inttostr(belA))).left := 110 - tlabel(form1.findcomponent('A' + inttostr(belA))).width div 2; end;
if atofield = 2 then begin inc(belB); tlabel(form1.findcomponent('B' + inttostr(belB))).caption := scheibe[n]; tlabel(form1.findcomponent('B' + inttostr(belB))).left := 110 - tlabel(form1.findcomponent('B' + inttostr(belB))).width div 2; end;
if atofield = 3 then begin inc(belC); tlabel(form1.findcomponent('C' + inttostr(belC))).caption := scheibe[n]; tlabel(form1.findcomponent('C' + inttostr(belC))).left := 110 - tlabel(form1.findcomponent('C' + inttostr(belC))).width div 2; end;
application.processmessages; sleep(strtoint(form1.edit2.text));
if n > 1 Then movetower (n - 1, ausingfield, atofield, afromfield); end;
procedure TForm1.Button1Click(Sender: TObject); begin n:=strtoint(form1.edit1.text); runde:=0; setlength(scheibe, n+1); scheibe[7]:='========'; scheibe[6]:='======='; scheibe[5]:='======'; scheibe[4]:='====='; scheibe[3]:='===='; scheibe[2]:='==='; scheibe[1]:='=='; belA:=n; belB:=0; belC:=0; movetower(n, 1, 3, 2); form1.listbox1.items.add('Es wurden ' + inttostr(runde) + ' Runden benötigt.'); end;
initialization {$I unit1.lrs}
end. |