Q&A

  • 도와 주세요
간단한 게임프로그램을 책을 보고 그대로 만들었는데

실행이 되지 않습니다.

왜 그런지 이유를 모르겠습니다.



소스와 오류메세지를 아래와 같이 등록하오니

부디부디 알려주시면 정말로 감사하겠습니다.



왕초보 드림

=========================================================================



소스



1. 레이블 3개

2. 에디트 창

3. 메모창

4. 버튼

5. 그리고 코드는 아래와 같습니다.

unit game1;



interface



uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls;



type

TForm1 = class(TForm)

Edit1: TEdit;

Memo1: TMemo;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;



procedure FormCreate(Sender: TObject);

procedure BtnStartClick(Sender: TObject);

procedure Edit1KeyPress(Sender: TObject; var Key:Char);

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;



var

Form1: TForm1;

comnum:string;

mynum:string;

times:integer;



implementation



{$R *.DFM}



procedure TForm1.FormCreate(Sender: TObject);

begin

randomize;{난수 루틴을 초기화 한다.}

Edit1.Enabled:=False;

label1.caption:='시작 버튼을 누르세요';



end;



procedure TForm1.BtnStartClick(Sender: TObject);

begin

Memo1.Lines.Clear;{기록내용을 지움}

{난수를 만들되 각 자리값이 중복되어서는

안되며 중간에 0 이 있어도 안된다.}

repeat

comnum:=IntToStr(random(900)+100);

Until (comnum[1]<>comnum[2]) and

(comnum[1]<>comnum[3]) and

(comnum[2]<>comnum[3]) and

(comnum[1]<>'0') and

(comnum[2]<>'0') and

(comnum[3]<>'0');

times:=0;

label1.caption:='숫자를 입력하십시요';

Edit1.Enabled:=True;

Edit1.SetFocus;

Edit1.SelectAll;



end;



procedure TForm1.Edit1KeyPress(Sender: TObject; var Key:Char);

var

S,B,i:inte0g0er;

begin

if Key<>#13 then Exit;{엔터키를 눌러야함}

{숫자 이외의 문자가 있거나 세자리 숫자가 아닌경우}

if (StrToIntDef(Edit1.Text,0)=0)

or (Length(Edit1.Text)<>3) then

begin

label1.caption:='세자리 숫자를 입력하십시요';

Edit1.SetFocus;

Edit1.selectAll;

Exit;

end;

times:=times+1;

S:=0;{스트라이크}

B:=0;{볼}

mynum:=Edit1.Text;

{스트라이크 개수를 센다}

for i:=1 to 3 do

if comnum[i]=mynum[i] then S:=S+1;

{볼개수를 센다}

if comnum[1]=mynum[2] then B:=B+1;

if comnum[1]=mynum[3] then B:=B+1;

if comnum[2]=mynum[1] then B:=B+1;

if comnum[2]=mynum[3] then B:=B+1;

if comnum[3]=mynum[1] then B:=B+1;

if comnum[3]=mynum[2] then B:=B+1;

{기록 내용을 메모로 출력한다}



Memo1.Lines.Add(Format('%s=%d 스트라이크%d볼',[mynum,S,B]));

{스트라이크가 셋이면 정답을 맞춘 것임}

if S=3 then

begin

showMessage('정답을 맞추었습니다. 축하합니다.');

Edit1.Enabled:=False;

label1.caption:='시작버튼을 누르십시요';

end

else

begin

label1.caption:='숫자를 입력하십시요';

Edit1.SetFocus;

Edit1.SelectAll;

end

end;



end.





6. 오류 메세지는 아래와 같습니다.



Exception EClassNotFound in module game11.exe at 0000C366

Class TButton not found.







부디 고매하신 고수님들의 하해와 같은 가르침을 기다리며

감히 왕초보 드립니다.



그럼 건강하시길



1  COMMENTS
  • Profile
    Ziker 2001.11.05 02:44
    안녕하세요.~

    음냐.. 소스에는 버튼을 쓰는걸로 되어 있는거 같은디

    실제 폼에 없는거 같은디요...



    프로시져까지 있는거 같고



    > type

    > TForm1 = class(TForm)

    > Edit1: TEdit;

    > Memo1: TMemo;

    > Label1: TLabel;

    > Label2: TLabel;

    > Label3: TLabel;



    이 부분에서 버튼이 정의 되어 있지 않습니다.



    그리고 에러 메시지도 버튼(TButton)클래스를 못 찾것다고

    즉 폼에 가져다 놓질 않았다고 하는군요.. 그럼...







    왕초보 wrote:

    > 간단한 게임프로그램을 책을 보고 그대로 만들었는데

    > 실행이 되지 않습니다.

    > 왜 그런지 이유를 모르겠습니다.

    >

    > 소스와 오류메세지를 아래와 같이 등록하오니

    > 부디부디 알려주시면 정말로 감사하겠습니다.

    >

    > 왕초보 드림

    > =========================================================================

    >

    > 소스

    >

    > 1. 레이블 3개

    > 2. 에디트 창

    > 3. 메모창

    > 4. 버튼

    > 5. 그리고 코드는 아래와 같습니다.

    > unit game1;

    >

    > interface

    >

    > uses

    > Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

    > StdCtrls;

    >

    > type

    > TForm1 = class(TForm)

    > Edit1: TEdit;

    > Memo1: TMemo;

    > Label1: TLabel;

    > Label2: TLabel;

    > Label3: TLabel;

    >

    > procedure FormCreate(Sender: TObject);

    > procedure BtnStartClick(Sender: TObject);

    > procedure Edit1KeyPress(Sender: TObject; var Key:Char);

    > procedure Button1Click(Sender: TObject);

    > private

    > { Private declarations }

    > public

    > { Public declarations }

    > end;

    >

    > var

    > Form1: TForm1;

    > comnum:string;

    > mynum:string;

    > times:integer;

    >

    > implementation

    >

    > {$R *.DFM}

    >

    > procedure TForm1.FormCreate(Sender: TObject);

    > begin

    > randomize;{난수 루틴을 초기화 한다.}

    > Edit1.Enabled:=False;

    > label1.caption:='시작 버튼을 누르세요';

    >

    > end;

    >

    > procedure TForm1.BtnStartClick(Sender: TObject);

    > begin

    > Memo1.Lines.Clear;{기록내용을 지움}

    > {난수를 만들되 각 자리값이 중복되어서는

    > 안되며 중간에 0 이 있어도 안된다.}

    > repeat

    > comnum:=IntToStr(random(900)+100);

    > Until (comnum[1]<>comnum[2]) and

    > (comnum[1]<>comnum[3]) and

    > (comnum[2]<>comnum[3]) and

    > (comnum[1]<>'0') and

    > (comnum[2]<>'0') and

    > (comnum[3]<>'0');

    > times:=0;

    > label1.caption:='숫자를 입력하십시요';

    > Edit1.Enabled:=True;

    > Edit1.SetFocus;

    > Edit1.SelectAll;

    >

    > end;

    >

    > procedure TForm1.Edit1KeyPress(Sender: TObject; var Key:Char);

    > var

    > S,B,i:inte0g0er;

    > begin

    > if Key<>#13 then Exit;{엔터키를 눌러야함}

    > {숫자 이외의 문자가 있거나 세자리 숫자가 아닌경우}

    > if (StrToIntDef(Edit1.Text,0)=0)

    > or (Length(Edit1.Text)<>3) then

    > begin

    > label1.caption:='세자리 숫자를 입력하십시요';

    > Edit1.SetFocus;

    > Edit1.selectAll;

    > Exit;

    > end;

    > times:=times+1;

    > S:=0;{스트라이크}

    > B:=0;{볼}

    > mynum:=Edit1.Text;

    > {스트라이크 개수를 센다}

    > for i:=1 to 3 do

    > if comnum[i]=mynum[i] then S:=S+1;

    > {볼개수를 센다}

    > if comnum[1]=mynum[2] then B:=B+1;

    > if comnum[1]=mynum[3] then B:=B+1;

    > if comnum[2]=mynum[1] then B:=B+1;

    > if comnum[2]=mynum[3] then B:=B+1;

    > if comnum[3]=mynum[1] then B:=B+1;

    > if comnum[3]=mynum[2] then B:=B+1;

    > {기록 내용을 메모로 출력한다}

    >

    > Memo1.Lines.Add(Format('%s=%d 스트라이크%d볼',[mynum,S,B]));

    > {스트라이크가 셋이면 정답을 맞춘 것임}

    > if S=3 then

    > begin

    > showMessage('정답을 맞추었습니다. 축하합니다.');

    > Edit1.Enabled:=False;

    > label1.caption:='시작버튼을 누르십시요';

    > end

    > else

    > begin

    > label1.caption:='숫자를 입력하십시요';

    > Edit1.SetFocus;

    > Edit1.SelectAll;

    > end

    > end;

    >

    > end.

    >

    >

    > 6. 오류 메세지는 아래와 같습니다.

    >

    > Exception EClassNotFound in module game11.exe at 0000C366

    > Class TButton not found.

    >

    >

    >

    > 부디 고매하신 고수님들의 하해와 같은 가르침을 기다리며

    > 감히 왕초보 드립니다.

    >

    > 그럼 건강하시길

    >