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:
| type TFach = (Deu,Eng,Fra,Rus,Lat,Kun,Mus,DS,Ges,PB,Geo,Mat,Phy,Che,Bio,Inf,Spo,Ast);
private EinbezogeneFaecher: Array[Deu..Ast] OF Boolean; Function Note(Fach:TFach;HalbJahr:Integer):Integer; Function LK(Fach:TFach):Boolean; Function BesteKomb(Fach:TFach):Integer; Procedure MarkBest(Fach:TFach;Index:Integer); Procedure MarkBest2(Fach:TFach;Index:Integer); public end;
var Form1: TForm1;
implementation
Function TForm1.Note; VAR name:String; i:Integer; Begin IF HalbJahr=0 THEN EXIT; name:='Edit'+ IntToStr(4*Integer(Fach)+ HalbJahr); FOR i:=0 TO ComponentCount-1 DO IF (Components[i] IS TEdit) AND ((Components[i] AS TEdit).Name=Name) THEN IF (Components[i] AS TEdit).Text ='' THEN Result:=0 ELSE Result:=StrToInt((Components[i] AS TEdit).Text); IF LK(Fach) THEN Result:=Result*2; END;
Function TForm1.LK; VAR name:String; i:Integer; Begin name:='LK'+ IntToStr(Integer(Fach)+1); FOR i:=0 TO ComponentCount-1 DO IF (Components[i] IS TCheckBox) AND ((Components[i] AS TCheckBox).Name=Name) THEN Result:=(Components[i] AS TCheckBox).Checked; END;
Procedure TForm1.MarkBest; VAR Name1:String; i:Integer; Begin IF Index=0 THEN EXIT; name1:='Edit'+ IntToStr(4*Integer(Fach)+ Index);
FOR i:=0 TO ComponentCount-1 DO IF (Components[i] IS TEdit) AND (((Components[i] AS TEdit).Name=Name1)) THEN (Components[i] AS TEdit).Color:=clRed; END;
Procedure TForm1.MarkBest2; VAR Name1:String; i:Integer; Begin IF Index=0 THEN EXIT; name1:='Edit'+ IntToStr(4*Integer(Fach)+ Index);
FOR i:=0 TO ComponentCount-1 DO IF (Components[i] IS TEdit) AND (((Components[i] AS TEdit).Name=Name1)) THEN (Components[i] AS TEdit).Color:=clGreen; END;
procedure TForm1.ZurueckClick(Sender: TObject); VAR I:iNTEGER; begin FOR i:=0 TO ComponentCount-1 DO BEGIN IF Components[i] IS TEdit THEN BEGIN (Components[i] AS TEdit).Text:=''; (Components[i] AS TEdit).Color:=clWhite; END;
IF Components[i] IS TCheckBox THEN (Components[i] AS TCheckBox).Checked:=False; END; end;
procedure TForm1.LK1Click(Sender: TObject); VAR I,anz:iNTEGER; begin anz:=0; FOR i:=0 TO ComponentCount-1 DO IF (Components[i] IS TCheckBox) AND ((Components[i] AS TCheckBox).Checked) THEN INC(Anz);
IF Anz>2 THEN (Sender AS TCheckBox).Checked:=False; end;
procedure TForm1.BerechneClick(Sender: TObject); VAR I,HJ,BesteNotenIndex:Integer; F,Bestes:TFach; Noten: ARRAY[Deu..Ast,1..2] OF Integer; Beste2Noten: Array[1..7] OF Record Summe:Integer; Fach:TFach; END; Beste1Note: Record Summe,HJ:Integer; Fach:TFach; END; begin FOR f:=Deu TO Ast DO EinbezogeneFaecher[f]:=False;
FOR i:=0 TO ComponentCount-1 DO IF Components[i] IS TEdit THEN (Components[i] AS TEdit).Color:=clWhite;
FOR i:=1 TO 2 DO FOR F:=Deu To Ast DO Noten[F,i]:= Note(F,i);
Beste1Note.Summe:=-1; Beste1Note.Hj:=-1; Beste1Note.Fach:=Deu;
FOR i:=1 TO 7 DO BEGIN Beste2Noten[i].Summe:=-1; Beste2Noten[i].Fach:=Deu; END;
BesteNotenIndex:=1; Beste2Noten[BesteNotenIndex].Summe:=Note(Mat,1)+Note(Mat,2); Beste2Noten[BesteNotenIndex].Fach:=Mat; EinbezogeneFaecher[Mat]:=True;
BesteNotenIndex:=2; Beste2Noten[BesteNotenIndex].Summe:=Note(Deu,1)+Note(Deu,2); Beste2Noten[BesteNotenIndex].Fach:=Deu; EinbezogeneFaecher[Deu]:=True;
FOR F:= Deu To Ast DO IF (NOT EinbezogeneFaecher[F]) AND (LK(F))THEN BEGIN INC(BesteNotenIndex); Beste2Noten[BesteNotenIndex].Summe:=Note(F,1)+Note(F,2); Beste2Noten[BesteNotenIndex].Fach:=F; EinbezogeneFaecher[F]:=True; END;
Bestes:=Eng; FOR F:=Fra TO Lat DO IF (Note(F,1)+Note(F,2))>(Note(Bestes,1)+Note(Bestes,2)) THEN Bestes:=F;
IF NOT EinbezogeneFaecher[Bestes] THEN BEGIN INC(BesteNotenIndex); Beste2Noten[BesteNotenIndex].Summe:=Note(Bestes,1)+Note(Bestes,2); Beste2Noten[BesteNotenIndex].Fach:=Bestes; EinbezogeneFaecher[Bestes]:=True; END;
Bestes:=Ges; FOR F:=Ges TO Geo DO IF (Note(F,1)+Note(F,2))>(Note(Bestes,1)+Note(Bestes,2)) THEN Bestes:=F;
IF NOT EinbezogeneFaecher[Bestes] THEN BEGIN INC(BesteNotenIndex); Beste2Noten[BesteNotenIndex].Summe:=Note(Bestes,1)+Note(Bestes,2); Beste2Noten[BesteNotenIndex].Fach:=Bestes; EinbezogeneFaecher[Bestes]:=True; END;
Bestes:=Phy; FOR F:=Phy TO Bio DO IF (Note(F,1)+Note(F,2))>(Note(Bestes,1)+Note(Bestes,2)) THEN Bestes:=F;
IF NOT EinbezogeneFaecher[Bestes] THEN BEGIN INC(BesteNotenIndex); Beste2Noten[BesteNotenIndex].Summe:=Note(Bestes,1)+Note(Bestes,2); Beste2Noten[BesteNotenIndex].Fach:=Bestes; EinbezogeneFaecher[Bestes]:=True; END;
WHILE BesteNotenIndex<=7 DO BEGIN Bestes:=Deu; While EinbezogeneFaecher[Bestes] DO INC(Bestes);
FOR F:=Deu TO Ast DO IF ((NOT EinbezogeneFaecher[F]) AND ((Note(F,1)+Note(F,2))>(Note(Bestes,1)+Note(Bestes,2)))) THEN Bestes:=F;
IF NOT EinbezogeneFaecher[Bestes] THEN BEGIN INC(BesteNotenIndex); Beste2Noten[BesteNotenIndex].Summe:=Note(Bestes,1)+Note(Bestes,2); Beste2Noten[BesteNotenIndex].Fach:=Bestes; EinbezogeneFaecher[Bestes]:=True; END;
END;
Bestes:=Deu;
While EinbezogeneFaecher[Bestes] DO INC(Bestes);
FOR F:=Deu TO Ast DO IF NOT EinbezogeneFaecher[F] AND ((Note(F,1)>Note(Bestes,1)) OR (Note(F,1)>Note(Bestes,2)) OR (Note(F,2)>Note(Bestes,1)) OR (Note(F,2)>Note(Bestes,2))) THEN Bestes:=F;
IF Note(Bestes,2)>Note(Bestes,1) THEN Beste1Note.Hj:=2 ELSE Beste1Note.Hj:=1;
Beste1Note.Summe:=Note(Bestes,Beste1Note.Hj);
Beste1Note.Fach:=Bestes; EinbezogeneFaecher[Bestes]:=True;
FOR i:=1 TO 7 DO BEGIN MarkBest(Beste2Noten[i].Fach,1); MarkBest(Beste2Noten[i].Fach,2); END;
MarkBest2(Beste1Note.Fach,Beste1Note.HJ);
end; |