Autor Beitrag
karatekid234
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Di 12.12.06 18:38 
ich bin mit meinem code ein wenig durcheinander gekommen. Ich bräuchte, dass am Ende das Erschaffen der Steine funktioniert (die paar letzten Zeilen). Bis dahin bin ich mit den create Befehlen durcheineander gekommen, vor allem, was den letzten Parameter betrifft. Was muss da hin? Habe ich die vorherigen richtig (also ich spreche jetzt von allen creates)?

ausblenden volle Höhe Delphi-Quelltext
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:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
unit Unit1;

interface

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

type

 Tturm = class (TCustomPanel)
  private
    { Private-Deklarationen }
     Fsize: integer;
    stab,bottom: TShape;
    procedure setsize(size: integer);
    function getsize: integer;
  public
    { Public-Deklarationen }
    constructor create(TurmTop, TurmLeft, TurmWidth, TurmHeight:integer; hinten: TComponent); virtual;
    property size:integer read getsize write setsize ;
    end;

  T3Turm = class(TTurm)
  private
  Fsize:integer;
  steine:array [0..8] of TShape;
  procedure setsize (size:integer);
  function getsize:integer;
  constructor create(STeinTop,STeinleft,Steinwidth,Steinheight:integer; hinten:TComponent); virtual;
  public
  property size:integer read getsize write setsize;
  end;


  TForm1 = class(TForm)
    Label1: TLabel;
    SpinEdit1: TSpinEdit;
    Label2: TLabel;
    TrackBar1: TTrackBar;
    Button1: TButton;
    Button2: TButton;
    SpinEdit2: TSpinEdit;
    Label3: TLabel;
    procedure FormCreate(Sender: TObject);
  private
   versuch:longint;
    procedure umsetzen(anzahl, von, nach, hilf : integer);
    procedure setze_eine(von,nach : integer);
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  spinx:Integer;
  Tturm1, Tturm2, Tturm3 : Tturm;
  tsteine:array [0..8] of T3Turm;
implementation


procedure TForm1.umsetzen(anzahl, von, nach, hilf : integer);
   begin
   if anzahl=1 then setze_eine(von,nach)
   else begin
       umsetzen(anzahl-1,von,hilf,nach);
       umsetzen(1,von,nach,hilf);
       umsetzen(anzahl-1,hilf,nach,von);
       end;
   end;

   procedure TForm1.setze_eine(von,nach : integer);
    var jetzt:integer;
   begin
   inc(versuch);
        Jetzt := GetTickCount + SpinEdit2.value;
        REPEAT
            Application.ProcessMessages;
        UNTIL GetTickCount > Jetzt;
   form1.Refresh;
   end;

   {$R *.dfm}
procedure Tturm.setsize(size: integer);
   var lauf: integer;
        raster:word;
   begin
   Fsize:=size;
   width:=size;
   height:=size;
   raster:=size div 20;
   end;

   function Tturm.getsize: integer;
   begin
   result:=Fsize;
   end;

   procedure T3Turm.setsize(size:integer);
   var lauf,raster:integer;
   begin
   Fsize:=size;
   for lauf:=0 to spinx-1 do begin
   steine[lauf].Left:=(lauf*10)+size+lauf;
   end;
   raster:=size div 20;
    end;

    function T3Turm.getsize:integer;
    begin
    result:=fsize;
    end;

    constructor T3Turm.create(SteinTop,SteinLeft, SteinWidth, SteinHeight:integer; hinten: TComponent);
    var lauf,raster:integer;
    begin
    for lauf:=0 to spinx-1 do begin
    raster:=size div 20;
    tsteine[lauf]:=T3Turm.create(self);
    end;
    fsize:=size;
    end;


   constructor Tturm.create(TurmTop, TurmLeft, TurmWidth, TurmHeight:integer; hinten: TComponent);
   var lauf :integer;
        raster:extended;
   begin
   inherited create(hinten);
   Parent:=TWincontrol(hinten);
   Top:=TurmTop;
   left:=TurmLeft;
   width:=TurmWidth;
   height:=TurmHeight;
   color:=clwhite;
   FSize:=TurmWidth;
   raster:=Fsize / 25;
     Stab:=TShape.create(self);
      Stab.Parent:=self;
         with stab do begin
           top:=round(12*raster);
           left:=round(24*raster / 2) ;
           width:=round(raster);
           height:=round(15*raster);
           brush.Color:=Clgray;
           pen.Color:=clgray;
         end;
           bottom:=tshape.create(self);
           bottom.parent:=self;
           with bottom do begin
           top:=round(26*raster);
           left:=round(raster);
           width:=round(23*raster);
           height:=round(2*raster);
           brush.Color:=clgray;
           end;
 end;

procedure TForm1.FormCreate(Sender: TObject);
var
  raster,lauf:integer;
  stein1:T3Turm;
begin
raster:=trackbar1.Position div 25;
spinx:=spinedit1.value;
if (tturm1<>nil) then tturm1.Free;
if (tturm2<>nil) then tturm2.Free;
if (tturm3<>nil) then tturm3.Free;
  tturm1:=Tturm.Create(75, 10, raster*6, raster*7, Form1);
  tturm2:=Tturm.Create(75, tturm1.width+20, raster*6,raster*7, Form1);
  tturm3:=Tturm.Create(75, tturm1.Width*2+30, raster*6,raster*7, Form1);
  for lauf:=0 to spinx-1 do begin
   tsteine[lauf]:=T3Turm.create(round(25*raster-lauf*raster),round((24*raster / 2)/3+lauf*raster),round(17*raster-lauf*raster*2),round(raster), Form1);
   end;

  end;

end.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 12.12.06 20:21 
Welche Fehler bekommst Du denn bzw. was klappt nicht? Mit einer besseren Beschreibung Deinerseits braucht man sich vielleicht nicht komplett einarbeiten, dann helfen sicherlich mehr Leute.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
karatekid234 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Di 12.12.06 20:26 
je nach meiner neuen Kombination : so wie Integer passt nicht zu int64 oder int64 nciht zu tshape oder t3turm nciht zu tshape.
also alle fehler sind jewails in den create befehlen
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 12.12.06 20:32 
Moin!

Sag mal, wenn ich mir so den Code und den aus den anderen Threads ansehe, dann habe ich Zweifel, ob du überhaupt verstanden hast, wie OOP funktioniert... ?! :? ;)

Meinst du nicht, du solltest mal ein OOP-Tutorial durchziehen und dich dann erst wieder an den Code setzen? :|

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.