| Autor |
Beitrag |
Stinger47
      
Beiträge: 102
|
Verfasst: Fr 24.03.06 14:19
ich arbeite gerade mit einem freund an nem schulprojekt für verschiedene klassen...(mathe-prog)
klappt bis jetzt alles wunderbar nur bei den brüchen haben wir mit der subtraktion ein kleines problem...
addition,multiplikation und division funktionieren nur halt nicht die subtraktion...
wenn wir die andren drei rechnungen ausdeklarieren funktioniert aba auch die subtraktion.....haben wir etwa zu viel code geht das???
die variablen spinnen auch net haben das auch schon überprüft und wenn wir das mit f7 durchrattern funktioniert auch immer alles einwandfrei....
sind am verzweifeln!!!
bitte helft uns!!
wichtig sind folgende punkte: procedure setMyEuklid //zeile 70 - 114
button1 ab klasse 6 //zeile 577 - 787
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: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709: 710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723: 724: 725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766: 767: 768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: 802: 803: 804: 805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824: 825: 826: 827: 828: 829: 830: 831: 832: 833: 834: 835: 836: 837: 838: 839: 840: 841: 842: 843: 844: 845: 846: 847: 848: 849: 850: 851: 852: 853: 854: 855: 856: 857: 858: 859: 860: 861: 862: 863: 864: 865: 866: 867: 868: 869: 870: 871: 872: 873: 874: 875: 876: 877: 878: 879: 880: 881: 882: 883: 884: 885: 886: 887: 888: 889: 890: 891: 892: 893: 894: 895: 896: 897: 898: 899: 900: 901: 902: 903: 904: 905: 906: 907: 908: 909: 910: 911: 912: 913: 914: 915: 916: 917: 918: 919: 920: 921: 922: 923: 924: 925: 926: 927: 928: 929: 930: 931: 932: 933: 934: 935: 936: 937: 938: 939: 940: 941: 942: 943: 944: 945: 946: 947: 948: 949: 950: 951: 952: 953: 954: 955: 956: 957: 958: 959: 960: 961: 962: 963: 964: 965: 966: 967: 968: 969: 970: 971: 972: 973: 974: 975: 976: 977: 978: 979: 980: 981: 982: 983: 984: 985: 986: 987: 988: 989: 990: 991: 992: 993: 994: 995: 996: 997: 998: 999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) Timer1: TTimer; Image1: TImage; Image2: TImage; Button1: TButton; Label1: TLabel; Label2: TLabel; RadioGroup1: TRadioGroup; Label3: TLabel; Edit1: TEdit; Button3: TButton; Button4: TButton; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; Edit2: TEdit; Label4: TLabel; procedure Button4Click(Sender: TObject); procedure RadioGroup1Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); private procedure Vorwärts(Bilder1,Weite1: Integer); procedure Rückwärts(Bilder2,Weite2: Integer); procedure Drehung(Bilder3: Integer); procedure SetMyEUklid(groß,klein: Integer); public end;
var Form1: TForm1; bildV,bildR: Integer; Bilder: String; Lösung: Boolean; zahl1,zahl2,zahl3,zahl4,zahl5,zahl6,zahl7,zahl8,zahl9,zahl10,zahl11,zahl12: Integer; Anzahl,Anzahl2,Anzahl3,Anzahl4,Falsch: Integer; Position1,Drehung1,Untergang: Integer; RechenZ: String; Rechenzeichen,Rechnung: Integer; BruchS,BruchA,BruchD,BruchM,BruchK: Boolean;
Const Pic= 'Bilder/bild1.bmp';
implementation
uses unit2,unit3;
{$R *.dfm}
procedure TForm1.SetMyEuklid(groß,klein: Integer); var LösungE, save: Integer; begin
while LösungE <> 0 do begin LösungE:= (groß - klein);
if LösungE > klein then begin groß:= LösungE; klein:= klein; end;
if klein > LösungE then begin groß:= klein; klein:= LösungE; end;
if (LösungE = klein) and (klein > 0) then save:= klein;
if (LösungE = klein) and (unit1.zahl5 mod save = 0) and (unit1.zahl8 mod save = 0) then begin groß:= LösungE; klein:= klein; end; end;
if LösungE = 0 then begin unit1.zahl6:= unit1.zahl5 div save; unit1.zahl11:= unit1.zahl8 div save; Form1.Label10.Caption:= IntToStr(unit1.zahl6); Form1.Label11.Caption:= IntToStr(unit1.zahl11); end;
end;
procedure TForm1.Vorwärts(Bilder1,Weite1: Integer); var Bilder: String; begin
Bilder:= 'Bilder/Bild'+IntToStr(Bilder1)+'.bmp';
Image2.Picture.LoadFromFile(Bilder);
if unit1.bildV>= 5 then Image2.Left:= Image2.Left + Weite1;
end;
procedure TForm1.Rückwärts(Bilder2,Weite2: Integer); var Bilder: String; begin
Bilder:= 'Bilder/Bild'+IntToStr(Bilder2)+'.bmp';
Image2.Picture.LoadFromFile(Bilder);
Image2.Left:= Image2.Left - Weite2;
end;
procedure TForm1.Drehung(Bilder3: Integer); var Bilder: String; begin
Bilder:= 'Bilder/Bild'+IntToStr(Bilder3)+'.bmp';
Image2.Picture.LoadFromFile(Bilder);
end;
procedure TForm1.Timer1Timer(Sender: TObject); begin
if Falsch >=1 then begin if (Anzahl< 5) and (BildV < 27) then begin
if Position1 > 0 then begin if Lösung= True then begin Inc(BildV); Vorwärts(BildV,15); end;
If Lösung= False then begin Rückwärts(BildR,15); BildR:= BildR - 1; end;
if bildV >= 13 then begin BildV:= 4; timer1.Enabled:= False; Button1.Enabled:= True; Button1.Visible:= True; end;
if BildR<= 4 then begin BildR:= 13; timer1.Enabled:= False; Button1.Enabled:= True; Button1.Visible:= True; end; end;
if (Position1 <= 0) and (Lösung = False) then begin If BildV<20 then begin Anzahl3:= Anzahl3 + 1; BildV:= BildV + 1; Bilder:= 'Bilder/Bild'+IntToStr(BildV)+'.bmp'; Image2.Picture.LoadFromFile(Bilder); end; if (BildV >= 5) and (Anzahl3 <= 5) then BildV:= 14; if BildV >= 20 then begin Bilder:= 'Bilder/Bild37.bmp'; image2.Picture.LoadFromFile(Bilder); Image2.Top:= Image2.Top + 5; if image2.Top >= 493 then begin timer1.Enabled:= False; showmessage('Du bekommst Krämpfe und scheidest leider aus!!'); end; end; end; end;
if Anzahl= 5 then begin if Lösung= True then begin Drehung(Drehung1); Drehung1:= Drehung1 + 1;
if Drehung1 >= 28 then begin Timer1.Enabled:= False; Button1.Enabled:= True; Button1.Visible:= True; BildV:= 27; BildR:= 36; Drehung1:= 27; end; end;
if Lösung= False then begin Vorwärts(BildR,15); BildR:= BildR - 1;
if BildR<= 27 then begin BildR:= 36; timer1.Enabled:= False; Button1.Enabled:= True; Button1.Visible:= True; end; end;
end;
if (Anzahl2 >= 5) and (Position1 = 4) and (Lösung = False) then begin Drehung(Drehung1); Drehung1:= Drehung1 - 1; if Drehung1 <= 12 then begin Timer1.Enabled:= False; Button1.Enabled:= True; button1.Visible:= True; BildV:= 4; BildR:= 13; end; end;
if Anzahl> 5 then begin
if Position1 > 0 then begin if Lösung= True then begin Inc(BildV); Rückwärts(BildV,15); end;
If Lösung= False then begin Vorwärts(BildR,15); BildR:= BildR - 1; end;
if bildV >= 36 then begin BildV:= 27; timer1.Enabled:= False; Button1.Enabled:= True; Button1.Visible:= True; end;
if BildR<= 27 then begin BildR:= 36; timer1.Enabled:= False; Button1.Enabled:= True; Button1.Visible:= True; end; end;
end; end;
if Falsch = 0 then begin Anzahl4:= anzahl4 + 1; if Anzahl4 <= 20 then begin Untergang:= Untergang + 1; Bilder:= 'Bilder/Bild'+IntToStr(Untergang)+'.bmp'; Image2.Picture.LoadFromFile(Bilder); end; if Untergang >= 20 then begin Bilder:= 'Bilder/Bild37.bmp'; image2.Picture.LoadFromFile(Bilder); Image2.Top:= Image2.Top + 5; if image2.Top >= 493 then begin timer1.Enabled:= False; showmessage('Du bekommst Krämpfe und scheidest leider aus!!'); end; end; end;
end;
procedure TForm1.FormCreate(Sender: TObject); begin
doublebuffered:= True; Randomize;
bildR:= 13; Position1:= 0; Drehung1:= 14; Falsch:= 3; Untergang:= 14;
end;
procedure TForm1.Button1Click(Sender: TObject); begin
Button1.Caption:= 'Weiter'; Button1.Left:= 232; Button1.Top:= 784;
if Radiogroup1.ItemIndex= 0 then begin
Rechenzeichen:= random(16) + 1;
case Rechenzeichen of 1: RechenZ:= '*'; 2: RechenZ:= '*'; 3: RechenZ:= '*'; 4: RechenZ:= '*'; 5: RechenZ:= '/'; 6: RechenZ:= '/'; 7: RechenZ:= '/'; 8: RechenZ:= '/'; 9: RechenZ:= '-'; 10: RechenZ:= '-'; 11: RechenZ:= '-'; 12: RechenZ:= '-'; 13: RechenZ:= '+'; 14: RechenZ:= '+'; 15: RechenZ:= '+'; 16: RechenZ:= '+'; end;
case Rechenzeichen of 1: begin zahl1:= 19; zahl2:= 19; end; 2: begin zahl1:= 19; zahl2:= 19; end; 3: begin zahl1:= 19; zahl2:= 19; end; 4: begin zahl1:= 19; zahl2:= 19; end; 5: begin zahl1:= 19; zahl2:= 19; end; 6: begin zahl1:= 19; zahl2:= 19; end; 7: begin zahl1:= 19; zahl2:= 19; end; 8: begin zahl1:= 19; zahl2:= 19; end; 9: begin zahl1:= 10000; zahl2:= 10000; end; 10: begin zahl1:= 10000; zahl2:= 10000; end; 11: begin zahl1:= 10000; zahl2:= 10000; end; 12: begin zahl1:= 10000; zahl2:= 10000; end; 13: begin zahl1:= 10000; zahl2:= 10000; end; 14: begin zahl1:= 10000; zahl2:= 10000; end; 15: begin zahl1:= 10000; zahl2:= 10000; end; 16: begin zahl1:= 10000; zahl2:= 10000; end; end;
zahl3:= random(zahl1) + 1; zahl4:= random(zahl2) + 1;
label3.Caption:= RechenZ; label4.Caption:= '=';
case Rechenzeichen of 1: begin zahl6:= zahl3 * zahl4; Label1.Caption:= IntToSTr(zahl3); Label2.Caption:= IntToSTr(zahl4); end;
2: begin zahl6:= zahl3 * zahl4; Label1.Caption:= IntToSTr(zahl3); Label2.Caption:= IntToSTr(zahl4); end;
3: begin zahl6:= zahl3 * zahl4; Label1.Caption:= IntToSTr(zahl3); Label2.Caption:= IntToSTr(zahl4); end;
4: begin zahl6:= zahl3 * zahl4; Label1.Caption:= IntToSTr(zahl3); Label2.Caption:= IntToSTr(zahl4); end;
13: begin zahl6:= zahl3 + zahl4; Label1.Caption:= IntToSTr(zahl3); Label2.Caption:= IntToSTr(zahl4); end;
14: begin zahl6:= zahl3 + zahl4; Label1.Caption:= IntToSTr(zahl3); Label2.Caption:= IntToSTr(zahl4); end;
15: begin zahl6:= zahl3 + zahl4; Label1.Caption:= IntToSTr(zahl3); Label2.Caption:= IntToSTr(zahl4); end;
16: begin zahl6:= zahl3 + zahl4; Label1.Caption:= IntToSTr(zahl3); Label2.Caption:= IntToSTr(zahl4); end; end;
if (Rechenzeichen >= 5) and (Rechenzeichen <= 12) then begin if (Rechenzeichen >= 5) and (Rechenzeichen <= 8) then begin zahl5:= zahl3 * zahl4; zahl6:= zahl5 div zahl4; label1.Caption:= IntToStr(zahl5); label2.Caption:= IntTOSTr(zahl4); end; if (Rechenzeichen >= 9) and (Rechenzeichen <= 12) then begin if zahl3 > zahl4 then begin zahl6:= zahl3 - zahl4; label1.Caption:= IntToStr(zahl3); Label2.Caption:= IntToStr(zahl4); end; if zahl3 < zahl4 then begin zahl6:= zahl4 - zahl3; label1.Caption:= IntToSTr(zahl4); label2.Caption:= IntTOStr(zahl3); end; end;
end; end;
if radiogroup1.ItemIndex = 1 then begin
Edit2.Enabled:= True; Edit2.Visible:= True;
BruchS:= True; If BruchM = True then begin
zahl1:= random(20) + 1; zahl2:= random(20) + 1; zahl3:= random(20) + 1; zahl4:= random(20) + 1;
Label1.Caption:= IntToStr(zahl1); Label7.Caption:= IntToStr(zahl2);
Label2.Caption:= IntToStr(zahl3); Label8.Caption:= IntToSTr(zahl4);
zahl5:= zahl1 * zahl3; zahl8:= zahl2 * zahl4;
if zahl5 > zahl8 then begin zahl9:= zahl5; zahl10:= zahl8; end;
if zahl8 > zahl5 then begin zahl9:= zahl8; zahl10:= zahl5; end;
SetMyEuklid(zahl9,zahl10);
end;
If BruchD = True then begin zahl1:= random(20) + 1; zahl2:= random(20) + 1; zahl3:= random(20) + 1; zahl4:= random(20) + 1;
Label1.Caption:= IntToStr(zahl1); Label7.Caption:= IntToStr(zahl2);
Label2.Caption:= IntToStr(zahl3); Label8.Caption:= IntToSTr(zahl4);
zahl5:= zahl1 * zahl4; zahl8:= zahl2 * zahl3;
if zahl5 > zahl8 then begin zahl9:= zahl5; zahl10:= zahl8; end;
if zahl8 > zahl5 then begin zahl9:= zahl8; zahl10:= zahl5; end;
SetMyEuklid(zahl9,zahl10);
end;
If BruchA = True then begin zahl1:= random(20) + 1; zahl2:= random(20) + 1; zahl3:= random(20) + 1; zahl4:= random(20) + 1;
Label1.Caption:= IntToStr(zahl1); Label7.Caption:= IntToStr(zahl2);
Label2.Caption:= IntToStr(zahl3); Label8.Caption:= IntToSTr(zahl4);
zahl5:= (zahl1 * zahl4) + (zahl3 * zahl2); zahl8:= (zahl2 * zahl4);
if zahl5 > zahl8 then begin zahl9:= zahl5; zahl10:= zahl8; end;
if zahl8 > zahl5 then begin zahl9:= zahl8; zahl10:= zahl5; end;
SetMyEuklid(zahl9,zahl10); end;
If BruchS = True then begin zahl1:= random(20) + 1; zahl2:= random(20) + 1; zahl3:= random(20) + 1; zahl4:= random(20) + 1;
if zahl3 < zahl1 then begin Label1.Caption:= IntToStr(zahl1); Label7.Caption:= IntToStr(zahl2);
Label2.Caption:= IntToStr(zahl3); Label8.Caption:= IntToSTr(zahl4); end;
if zahl1 < zahl3 then begin Label1.Caption:= IntToStr(zahl3); Label7.Caption:= IntToStr(zahl4);
Label2.Caption:= IntToStr(zahl1); Label8.Caption:= IntToSTr(zahl2); end;
if zahl3 < zahl1 then begin zahl5:= (zahl1 * zahl4) - (zahl3 * zahl2); zahl8:= (zahl2 * zahl4); end;
if zahl1 < zahl3 then begin zahl5:= (zahl3 * zahl2) - (zahl1 * zahl4); zahl8:= (zahl2 * zahl4); end;
if zahl5 > zahl8 then begin zahl9:= zahl5; zahl10:= zahl8; end;
if zahl8 > zahl5 then begin zahl9:= zahl8; zahl10:= zahl5; end;
SetMyEuklid(zahl9,zahl10); end;
end;
Button1.Enabled:= False; Button1.Visible:= False; Button3.Enabled:= True; Button3.Visible:= True; Edit1.Visible:= True; Edit1.Enabled:= True; Radiogroup1.Enabled:= False;
label5.Caption:= IntToStr(Rechenzeichen); label6.Caption:= IntToStr(zahl6);
end;
procedure TForm1.Button3Click(Sender: TObject); begin
if Radiogroup1.ItemIndex = 0 then begin
Inc(Anzahl2);
if (Anzahl <= 11) and (Position1 < 10) then begin
zahl7:= StrToInt(edit1.Text);
if zahl7 = zahl6 then begin Position1:= Position1 + 1; Lösung:= True; Timer1.Enabled:= True; Anzahl:= Anzahl + 1; end;
if zahl7 <> zahl6 then begin Position1:= Position1 - 1; Lösung:= False; Timer1.Enabled:= True; Anzahl:= Anzahl-1; Falsch:= Falsch - 1; end;
Button3.Enabled:= False; Button3.Visible:= False;
if Position1 <= 0 then begin timer1.Enabled:= True; button4.Enabled:= True; button4.Visible:= True; end;
Edit1.Text:= '';
end;
if (Anzahl = 10) and (Falsch = 3) then begin form1.Visible:= False; form2.Visible:= True; end;
if (Anzahl = 10) and (Falsch = 2) then begin form1.Visible:= False; form2.Visible:= True; form2.Label1.Caption:= 'Du bist Zweiter!!'; end;
if (Anzahl = 10) and (Falsch = 1) then begin form1.Visible:= False; form2.Visible:= True; form2.Label1.Caption:= 'Du bist leider nur Dritter!'; end;
if Falsch = 0 then begin button1.Enabled:= False; button1.Visible:= False; button4.Enabled:= True; button4.Visible:= True; end; end;
If Radiogroup1.ItemIndex = 1 then begin Inc(Anzahl2);
if (Anzahl <= 11) and (Position1 < 10) then begin
zahl7:= StrToInt(edit1.Text); zahl12:= StrToInt(edit2.Text);
if (zahl7 = zahl6) and (zahl12 = zahl11) then begin Position1:= Position1 + 1; Lösung:= True; Timer1.Enabled:= True; Anzahl:= Anzahl + 1; end;
if (zahl7 <> zahl6) or (zahl12 <> zahl11) then begin Position1:= Position1 - 1; Lösung:= False; Timer1.Enabled:= True; Anzahl:= Anzahl-1; Falsch:= Falsch - 1; end;
Button3.Enabled:= False; Button3.Visible:= False;
if Position1 <= 0 then begin timer1.Enabled:= True; button4.Enabled:= True; button4.Visible:= True; end;
Edit1.Text:= '';
end;
if (Anzahl = 10) and (Falsch = 3) then begin form1.Visible:= False; form2.Visible:= True; end;
if (Anzahl = 10) and (Falsch = 2) then begin form1.Visible:= False; form2.Visible:= True; form2.Label1.Caption:= 'Du bist Zweiter!!'; end;
if (Anzahl = 10) and (Falsch = 1) then begin form1.Visible:= False; form2.Visible:= True; form2.Label1.Caption:= 'Du bist leider nur Dritter!'; end;
if Falsch = 0 then begin button1.Enabled:= False; button1.Visible:= False; button4.Enabled:= True; button4.Visible:= True; end; end;
end;
procedure TForm1.RadioGroup1Click(Sender: TObject); begin
if (radiogroup1.ItemIndex= 0) or (radiogroup1.ItemIndex= 1) or (radiogroup1.ItemIndex= 2) or (radiogroup1.ItemIndex= 3) or (radiogroup1.ItemIndex= 4) or (radiogroup1.ItemIndex= 5) then button1.Enabled:= True; end;
procedure TForm1.Button4Click(Sender: TObject); begin
bildR:= 13; Position1:= 0; Anzahl:= 0; BildV:= 0; Anzahl2:= 0;
Button1.Left:= 16; button1.Top:= 824; Button1.Enabled:= True; Button1.Visible:= True;
Button4.Enabled:= False; Button4.Visible:= False;
Image2.Left:= 3; Image2.Picture.LoadFromFile(Pic);
Radiogroup1.Enabled:= True;
Falsch:= 3;
image2.Top:= 248; image2.Left:= 3;
end;
end. |
danke schonma im voraus... 
Zuletzt bearbeitet von Stinger47 am Fr 24.03.06 15:25, insgesamt 1-mal bearbeitet
|
|
jaenicke
      
Beiträge: 19346
Erhaltene Danke: 1754
W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: Fr 24.03.06 14:49
Erstens erinnere ich mal an die Foren-Richtlinien!
Bitte ändere den Titel des Topics, da "zu viel code???" nichts über das Thema dieses Topics verrät. Hier der entsprechende Absatz aus den Richtlinien:
| 1.2 Beiträge: | | Bitte formuliere den Betreff Deiner Beiträge so, dass andere Mitglieder anhand dieser bereits das eigentliche Thema festmachen können. Beiträge wie etwa "Eine Anfängerfrage" oder "Weiß jemand, wie das geht?" lassen den Leser im Unklaren darüber, was das Thema der Diskussion ist.[...] |
Dafür musst du nur oben bei deinem ersten Beitrag auf  klicken und dort den Titel ändern.
Zweitens:
Wenn du einen so langen Quelltext postest, dann schreib bitte genauer, wo (in welchen Zeilen) eigentlich das passiert, was nicht funktioniert! Aber die angegebenen Punkte finde ich ja hoffentlich auch so, die Prozedur hast du ja angegeben. Zeilennummern wären aber sinnvoller gewesen...
Aber vor allem poste auch die dfm-Datei, damit wir auch das Formular haben, sonst können wir ja gar nicht kompilieren.
Am besten packst du einfach alles in eine Zip-Datei und hängst die an deinen Beitrag an (Unterhalb des Eingabefensters steht Dateianhang hinzufügen). Denn hier im Browser kann ich mit so viel Code sowieso nichts anfangen! Die Exe solltest du weglassen, damit die Datei nicht so groß ist.
Jedenfalls sehe ichs mir mal an, aber ohne das Formular.. Na mal sehen...
|
|
fidionael
      
Beiträge: 232
Win XP SP2, Ubuntu 6.06
Delphi 7 PE, Delphi 3 Prof
|
Verfasst: Fr 24.03.06 15:33
Okay ich versuche einfach mal mich durch euren Quelltext zu wühlen, auch wenn es eindeutig zu viel ist *gg*
Erstmal würde ich anstatt eure meterlangen Variablen-Deklarationen
| Zitat: | Delphi-Quelltext 1: 2:
| zahl1,zahl2,zahl3,zahl4,zahl5,zahl6,zahl7,zahl8,zahl9,zahl10,zahl11,zahl12: Integer; Anzahl,Anzahl2,Anzahl3,Anzahl4,Falsch: Integer; | |
lieber Arrays benutzen:
Delphi-Quelltext 1: 2: 3:
| zahl: Array[1..12] of Integer; anzahl: Array[1..4] of Integer; falsch: Integer; |
Ihr ruft dann die Variablen im Programm via zahl[index] auf.
Und zweitens ist mir Folgendes aufgefallen:
| Zitat: | Delphi-Quelltext 1: 2: 3: 4: 5: 6:
| procedure TForm1.SetMyEuklid(groß,klein: Integer); var LösungE, save: Integer; begin
while LösungE <> 0 [...] | |
Da greift ihr auf eine lokale Variable zu, bevor sie intialisiert wurde, ihr müsst LösungE vorher irgendeinen Startwert zuweisen.
Weiter hab ich bis jetzt noch nicht geguckt ich edite falls nötig nochmal, aber vllt hilft euch das ja schonmal.
//Edit:
Ihr verändert in euerm Quelltext Variablen und stellt direkt danach if-Abfragen. Ich weiß nicht ob das gewollt ist, da die if-Abfragen dann bereits mit den neu-zugewiesenen Werten hantieren.
Falls das nicht ist, was ihr wollt, benutzt eine if-else-Abfrage:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8:
| if LösungE>klein then begin end else if LösungE<klein then begin end; |
Mir sind auch noch meterlange Case-Abfragen aufgefallen:
| Zitat: | Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17:
| case Rechenzeichen of 1: RechenZ:= '*'; 2: RechenZ:= '*'; 3: RechenZ:= '*'; 4: RechenZ:= '*'; 5: RechenZ:= '/'; 6: RechenZ:= '/'; 7: RechenZ:= '/'; 8: RechenZ:= '/'; 9: RechenZ:= '-'; 10: RechenZ:= '-'; 11: RechenZ:= '-'; 12: RechenZ:= '-'; 13: RechenZ:= '+'; 14: RechenZ:= '+'; 15: RechenZ:= '+'; 16: RechenZ:= '+'; | |
Dafür gibt es einen hübschen kleinen Trick:
Delphi-Quelltext 1: 2: 3: 4: 5: 6:
| case Rechenzeichen of 1..4: RechenZ:='*'; 5..8: RechenZ:='/'; 9..12: RechenZ:='-'; 13..16: RechenZ:='+'; end; |
Nochmal hier:
| Zitat: | 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:
| case Rechenzeichen of 1: begin zahl1:= 19; zahl2:= 19; end; 2: begin zahl1:= 19; zahl2:= 19; end; 3: begin zahl1:= 19; zahl2:= 19; end; 4: begin zahl1:= 19; zahl2:= 19; end; 5: begin zahl1:= 19; zahl2:= 19; end; 6: begin zahl1:= 19; zahl2:= 19; end; 7: begin zahl1:= 19; zahl2:= 19; end; 8: begin zahl1:= 19; zahl2:= 19; end; 9: begin zahl1:= 10000; zahl2:= 10000; end; 10: begin zahl1:= 10000; zahl2:= 10000; end; 11: begin zahl1:= 10000; zahl2:= 10000; end; 12: begin zahl1:= 10000; zahl2:= 10000; end; 13: begin zahl1:= 10000; zahl2:= 10000; end; 14: begin zahl1:= 10000; zahl2:= 10000; end; 15: begin zahl1:= 10000; zahl2:= 10000; end; 16: begin zahl1:= 10000; zahl2:= 10000; end; end; | |
Besser wäre:
Delphi-Quelltext 1: 2: 3: 4:
| case Rechenzeichen of 1..8: for i:=1 to 2 do zahl[i]:=19; 9..16: for i:=1 to 2 do zahl[i]:=10000; end; |
Das kürzt den Quelltext schon gewaltig
//Edit:
OMG eure ButtonClick-Prozedur ist über 300 Zeilen lang... Kein Wunder das ihr fürs Debugging die Hilfe des Delphi-Forums braucht *g*
Macht doch besser die einzelnen Sinnabschnitte in Unterprozeduren, die ihr private im Formular deklariert, dann wirds viel übersichtlicher.
Übrigens würd ich euch empfehlen, euch mal in die OOP (objektorientierte Programmierung) einzufinden, da kann man so unendlich lange quelltexte sinnvoll und übersichtlich strukturieren. Insgesamt scheint es mir, dass ihr euch für eure jetzigen Delphi-Kenntnisse ein wenig übernommen habt (quantitätsmäßig nicht unbedingt vom Anspruch) und erstmal einige Grundlagen anlernen bzw. wiederholen solltet, bevor ihr ernsthaft weiterkommen werdet.
//Edit:
In eurer 6. Klasse hab ich noch einiges gefunden, ich weiß es war auskommentiert und man sollte es eigentlich ignorieren, aber ihr möchtet es ja bestimmt irgendwann wieder hinzubinden und das geht viel schöner*g*:
| Zitat: | Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22:
| case Rechnung of 1: BruchS:= True; 2: BruchA:= True; 3: BruchD:= True; 4: BruchM:= True; 5: BruchK:= True; 6: BruchS:= True; 7: BruchA:= True; 8: BruchD:= True; 9: BruchM:= True; 10: BruchK:= True; 11: BruchS:= True; 12: BruchA:= True; 13: BruchD:= True; 14: BruchM:= True; 15: BruchK:= True; 16: BruchS:= True; 17: BruchA:= True; 18: BruchD:= True; 19: BruchM:= True; 20: BruchK:= True; end; | |
Die schönere Lösung:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10:
| Bruch: Array[1..5] of Boolean;
[...]
case (Rechnung mod 5) of 0: Bruch[5]:=True; 1..4: Bruch[Rechnung mod 5]:=True; end; |
|
|
|