{ Programmeerinud: Merle Mumme M-21 } { Piret Palmiste M-21 } Program Piletimyyk_Loomaaias; Uses CRT,printer; Type LapseAndmed = RECORD Kokku : Byte; TaP,KuP, KvP : Real; TaM, Kum, KvM : Byte; END; OpilasAndmed = RECORD Kokku : Byte; TaP, KuP, KvP : Real; TaM, Kum, KvM : Byte; END; TaisAndmed = RECORD Kokku : Byte; TaP, KuP, KvP : Real; TaM, Kum, KvM : Byte; END; Var LA : file of LapseAndmed; OA : file of OpilasAndmed; TA : file of TaisAndmed; Laps : LapseAndmed; Opilane : OpilasAndmed; Suur : TaisAndmed; X, Y, N : Integer; C, D : Char; S : String; Y2 : Integer; Tyyp : string; Mitmes : Byte; Hind : Real; I : Integer; R : Real; ST1 : String; procedure mode(back, fore : byte); begin textbackground(back); textcolor(fore); end; procedure kursor_tagasi; begin asm mov ah, 1 mov ch, 6 mov cl, 7 int 10h end end; procedure kaota_kursor; begin asm mov ah, 1 mov ch, 1 mov cl, 0 int 10h end end; procedure Lopeta; begin clrscr; textmode(lastmode); kursor_tagasi; halt(0); end; procedure TeeUus; begin Assign(LA, 'laps.dat'); Rewrite(LA); Assign(OA, 'opilane.dat'); Rewrite(OA); Assign(TA, 'taiskasv.dat'); Rewrite(TA); Laps.Kokku := 0; Opilane.Kokku := 0; Suur.Kokku := 0; Laps.TaP := 0; Opilane.TaP := 0; Suur.TaP := 0; Laps.KuP := 0; Opilane.KuP := 0; Suur.KuP := 0; Laps.KvP := 0; Opilane.KvP := 0; Suur.KvP := 0; Laps.TaM := 0; Laps.KuM := 0; Laps.KvM := 0; Opilane.TaM := 0; Opilane.KuM := 0; Opilane.KvM := 0; Suur.TaM := 0; Suur.KuM := 0; Suur.KvM := 0; Seek(LA,0); Write(LA, Laps); Seek(OA,0); Write(OA, Opilane); Seek(TA,0); Write(TA, Suur); end; procedure fopen; begin Assign(LA, 'laps.dat'); Assign(OA, 'opilane.dat'); Assign(TA, 'taiskasv.dat'); {$i-} Reset(LA); Reset(OA); Reset(TA); {$i+} if IOResult <> 0 then TeeUus; Seek(LA,0); Read(LA, Laps); Seek(OA,0); Read(OA, Opilane); Seek(TA,0); Read(TA, Suur); end; procedure fclose; begin Close(LA); Close(OA); Close(TA); end; procedure joonistakast; begin mode(0,3); gotoxy(01,18); Write(''); gotoxy(23,18); Write(''); gotoxy(01,25); Write(''); gotoxy(23,25); Write(''); gotoxy(02,18); for n := 1 to 21 do Write(''); gotoxy(02,25); for n := 1 to 21 do Write(''); for n := 19 to 24 do begin gotoxy(01,n); Write(''); gotoxy(23,n); Write(''); end; mode(4,14); gotoxy(02,19); Write(' Uus lapsepilet '); mode(0,14); gotoxy(02,20); Write(' Uus pilasepilet '); gotoxy(02,21); Write(' Uus tisealisepilet '); gotoxy(02,22); Write(' Muuda hindu '); gotoxy(02,23); Write(' Kokkuvtted '); gotoxy(02,24); Write(' Lahkuda DOS-i '); end; procedure KaotaYmbris; begin mode(01,01); gotoxy(20,09); Write(' '); gotoxy(20,10); Write(' '); gotoxy(20,11); Write(' '); gotoxy(20,12); Write(' '); gotoxy(20,13); Write(' '); gotoxy(20,14); Write(' '); gotoxy(20,15); Write(' '); gotoxy(26,Y2); end; procedure Print; begin Writeln(lst,' + Loomaaaed +ͻ'); Writeln(lst,' $ $'); Writeln(lst,' Tp :',tyyp:26 ,' '); Writeln(lst,' Number :',mitmes:2,' '); Writeln(lst,' Hind :',hind:7:2, ' '); Writeln(lst,' $ $'); Writeln(lst,' ͼ'); end; procedure PiletiYmbris; Var Ch : Char; begin mode(11,15); gotoxy(20,09); Write('+ Loomaaaed +ͻ'); gotoxy(20,10); Write('$ $'); gotoxy(20,11); Write(' Tp : '); gotoxy(20,12); Write(' Number : '); gotoxy(20,13); Write(' Hind : '); gotoxy(20,14); Write('$ $'); gotoxy(20,15); Write('ͼ'); mode(11,00); gotoxy(31,11); Write(Tyyp); gotoxy(32,12); Write(Mitmes); gotoxy(32,13); Write(Hind:7:2); { Print;} Repeat Ch := Readkey; Until Ord(ch)=27; KaotaYmbris; end; procedure Uus2(pTyyp : string; kes : string); const paev = ' HEPEVAPILET '; kuu = ' KUUPILET '; kvartal = ' KVARTALIPILET '; _laps = '| LAPS '; _opil = '| PILANE '; _suur = '| TISEALINE '; begin if pTyyp = 'tava' then tyyp := paev; if pTyyp = 'kuu' then tyyp := kuu; if pTyyp = 'kvartal' then tyyp := kvartal; if kes = 'laps' then begin if pTyyp = 'tava' then begin inc(Laps.TaM); Mitmes := Laps.TaM; Hind := Laps.TaP; end; if pTyyp = 'kuu' then begin inc(Laps.KuM); Mitmes := Laps.KuM; Hind := Laps.KuP; end; if pTyyp = 'kvartal' then begin inc(Laps.KvM); Mitmes := Laps.KvM; Hind := Laps.KvP; end; tyyp :=tyyp+_laps; Inc(Laps.Kokku); Seek(LA,0); Write(LA, Laps); Seek(LA,0); Read(LA, Laps); end else if kes = 'opil' then begin if pTyyp = 'tava' then begin inc(Opilane.TaM); Mitmes := Opilane.TaM; Hind := Opilane.TaP; end; if pTyyp = 'kuu' then begin inc(Opilane.KuM); Mitmes := Opilane.KuM; Hind := Opilane.KuP; end; if pTyyp = 'kvartal' then begin inc(Opilane.KvM); Mitmes := Opilane.KvM; Hind := Opilane.KvP; end; tyyp := tyyp+_opil; Inc(Opilane.Kokku); Seek(OA,0); Write(OA, Opilane); Seek(OA,0); Read(OA, Opilane); end else if kes = 'suur' then begin if pTyyp = 'tava' then begin inc(Suur.TaM); Mitmes := Suur.TaM; Hind := Suur.TaP; end; if pTyyp = 'kuu' then begin inc(Suur.KuM); Mitmes := Suur.KuM; Hind := Suur.KuP; end; if pTyyp = 'kvartal' then begin inc(Suur.KvM); Mitmes := Suur.KvM; Hind := Suur.KvP; end; tyyp := tyyp+_suur; Inc(Suur.Kokku); Seek(TA,0); Write(TA, Suur); Seek(TA,0); Read(TA, Suur); end; PiletiYmbris; end; Procedure PiletiTyyp_Vali; begin if (Y2 = 19) and (Y = 19) then Uus2('tava', 'laps') else if (Y2 = 20) and (Y = 19) then Uus2('kuu', 'laps') else if (Y2 = 21) and (Y = 19) then Uus2('kvartal','laps') else if (Y2 = 19) and (Y = 20) then Uus2('tava', 'opil') else if (Y2 = 20) and (Y = 20) then Uus2('kuu', 'opil') else if (Y2 = 21) and (Y = 20) then Uus2('kvartal','opil') else if (Y2 = 19) and (Y = 21) then Uus2('tava', 'suur') else if (Y2 = 20) and (Y = 21) then Uus2('kuu', 'suur') else if (Y2 = 21) and (Y = 21) then Uus2('kvartal','suur'); end; procedure Tagasi; begin mode(1,1); gotoxy(25,18); Write(' '); gotoxy(25,19); Write(' '); gotoxy(25,20); Write(' '); gotoxy(25,21); Write(' '); gotoxy(25,22); Write(' '); Gotoxy(02,Y); end; procedure Liigu2(kuhu : string); begin if (kuhu = 'yles') and (Y2 <= 19) or (kuhu = 'alla') and (Y2 >= 21) then Exit else mode(0,14); gotoxy(26,19); Write(' hepevapilet '); gotoxy(26,20); Write(' Kuupilet '); gotoxy(26,21); Write(' Kvartalipilet '); mode(4,14); if kuhu = 'yles' then Dec(Y2); if kuhu = 'alla' then Inc(Y2); if Y2 = 19 then s := ' hepevapilet ' else if Y2 = 20 then s := ' Kuupilet ' else if Y2 = 21 then s := ' Kvartalipilet '; gotoxy(26, Y2); Write(s); end; procedure Uus_Kast; begin mode(0,3); gotoxy(25,18); Write(''); gotoxy(45,18); Write(''); gotoxy(25,22); Write(''); gotoxy(45,22); Write(''); gotoxy(26,18); for n := 1 to 19 do Write(''); gotoxy(26,22); for n := 1 to 19 do Write(''); for n := 19 to 21 do begin gotoxy(25,n); Write(''); gotoxy(45,n); Write(''); end; mode(0,14); gotoxy(26,19); Write(' hepevapilet '); gotoxy(26,20); Write(' Kuupilet '); gotoxy(26,21); Write(' Kvartalipilet '); mode(4,14); Y2 := 19; gotoxy(26,19); Write(' hepevapilet '); Repeat C := ReadKey; if ord(c)=0 then begin D := ReadKey; if ord(d) = 72 then Liigu2('yles') else if ord(d) = 80 then Liigu2('alla') else end else if ord(c) = 13 then PiletiTyyp_Vali else if ord(c) = 27 then Tagasi else Until ord(c) = 27; end; procedure get(tmpy : integer); label valesti, tyhistr; var st2 : string; Code : Integer; begin st1 := ''; gotoxy(65,tmpy); mode(00,15); repeat until keypressed; valesti: gotoxy(65,tmpy); Write(' '); gotoxy(65,tmpy); Readln(st1); if st1='' then goto tyhistr else if pos(',',st1)<>0 then begin insert('.',st1,pos(',',st1)); delete(st1,pos(',',st1),1); end; Val(st1, R, Code); if Code <> 0 then goto valesti else if (R<0) or (R>9999) then goto valesti else tyhistr: end; procedure Muuda_Hindu; var tmpx, tmpy : integer; ch : char; begin mode(0,14); gotoxy(30,08); Write(''); gotoxy(75,08); Write(''); gotoxy(30,21); Write(''); gotoxy(75,21); Write(''); gotoxy(31,08); for n := 1 to 44 do Write(''); gotoxy(31,21); for n := 1 to 44 do Write(''); for n := 09 to 20 do begin gotoxy(30,n); Write(''); gotoxy(75,n); Write(''); end; mode(00,15); gotoxy(31,09); Writeln(' Hinnakirja muutmine (Enteri vajutamine '); gotoxy(31,10); Writeln(' mingil vljal jtab vlja muutmata) '); mode(00,10); gotoxy(31,11); Writeln(' '); gotoxy(31,12); Writeln(' HEPEVAPILET lapsele .....: EEK '); gotoxy(31,13); Writeln(' ... pilasele .....: EEK '); gotoxy(31,14); Writeln(' ... tisealisele .....: EEK '); gotoxy(31,15); Writeln(' KUUPILET lapsele .....: EEK '); gotoxy(31,16); Writeln(' ... pilasele .....: EEK '); gotoxy(31,17); Writeln(' ... tisealisele .....: EEK '); gotoxy(31,18); Writeln(' KVARTALIPILET lapsele .....: EEK '); gotoxy(31,19); Writeln(' ... pilasele .....: EEK '); gotoxy(31,20); Writeln(' ... tisealisele .....: EEK '); mode(00,07); gotoxy(65,12); Writeln(Laps.TaP:7:2); gotoxy(65,13); Writeln(Laps.KuP:7:2); gotoxy(65,14); Writeln(Laps.KvP:7:2); gotoxy(65,15); Writeln(Opilane.TaP:7:2); gotoxy(65,16); Writeln(Opilane.KuP:7:2); gotoxy(65,17); Writeln(Opilane.KvP:7:2); gotoxy(65,18); Writeln(Suur.TaP:7:2); gotoxy(65,19); Writeln(Suur.KuP:7:2); gotoxy(65,20); Writeln(Suur.KvP:7:2); get(12); if st1<>'' then Laps.TaP := R; gotoxy(65,12); Writeln(Laps.TaP:7:2); get(13); if st1<>'' then Laps.KuP := R; gotoxy(65,13); Writeln(Laps.KuP:7:2); get(14); if st1<>'' then Laps.KvP := R; gotoxy(65,14); Writeln(Laps.KvP:7:2); get(15); if st1<>'' then Opilane.TaP := R; gotoxy(65,15); Writeln(Opilane.TaP:7:2); get(16); if st1<>'' then Opilane.KuP := R; gotoxy(65,16); Writeln(Opilane.KuP:7:2); get(17); if st1<>'' then Opilane.KvP := R; gotoxy(65,17); Writeln(Opilane.KvP:7:2); get(18); if st1<>'' then Suur.TaP := R; gotoxy(65,18); Writeln(Suur.TaP:7:2);; get(19); if st1<>'' then Suur.KuP := R; gotoxy(65,19); Writeln(Suur.KuP:7:2); get(20); if st1<>'' then Suur.KvP := R; gotoxy(65,20); Writeln(Suur.KvP:7:2); Seek(LA,0); Write(LA,Laps); Seek(OA,0); Write(OA,Opilane); Seek(TA,0); Write(TA,Suur); repeat ch := readkey; until ord(ch)=27; mode(1,1); for tmpy := 08 to 21 do begin for tmpx := 30 to 75 do begin gotoxy(tmpx,tmpy); write(' '); end; end; gotoxy(02,Y); end; procedure Kokkuvotted; var Ch : Char; TmpX, TmpY : Integer; Total : Real; begin Total := 0; mode(00,14); gotoxy(30,08); Write(''); gotoxy(75,08); Write(''); gotoxy(30,25); Write(''); gotoxy(75,25); Write(''); gotoxy(31,08); for n := 1 to 44 do Write(''); gotoxy(31,25); for n := 1 to 44 do Write(''); for n := 09 to 24 do begin gotoxy(30,n); Write(''); gotoxy(75,n); Write(''); end; mode(00,15); gotoxy(31,09); Writeln(' Piletimgi kokkuvtted '); gotoxy(31,10); Writeln(' '); mode(00,10); gotoxy(31,11); Writeln(' hepevapileteid mdud ...: '); gotoxy(31,12); Writeln(' raha ...: '); gotoxy(31,13); Writeln(' Kuupileteid mdud ........: '); gotoxy(31,14); Writeln(' raha ...: '); gotoxy(31,15); Writeln(' Kvartalipileteid mdud ...: '); gotoxy(31,16); Writeln(' raha ...: '); gotoxy(31,17); Writeln(' Lastepileteid kokku .......: '); gotoxy(31,18); Writeln(' raha ...: '); gotoxy(31,19); Writeln(' pilasepileteid kokku .....: '); gotoxy(31,20); Writeln(' raha ...: '); gotoxy(31,21); Writeln(' Tisealisepileteid kokku ..: '); gotoxy(31,22); Writeln(' raha ...: '); mode(00,11); gotoxy(31,23); Writeln(' KIKI PILETEID KOKKU ------: '); gotoxy(31,24); Writeln(' RAHA KOKKU ----------------: '); mode(0,15); gotoxy(61,11); Write(Laps.TaM+Opilane.TaM+Suur.TaM); gotoxy(61,13); Write(Laps.KuM+Opilane.KuM+Suur.KuM); gotoxy(61,15); Write(Laps.KvM+Opilane.KvM+Suur.KvM); gotoxy(61,17); Write(Laps.Kokku); gotoxy(61,19); Write(Opilane.Kokku); gotoxy(61,21); Write(Suur.Kokku); gotoxy(61,23); Write(Laps.Kokku+Opilane.Kokku+Suur.Kokku); mode(00,14); gotoxy(61,12); Write((Laps.TaP*Laps.TaM)+(Opilane.TaP*Opilane.TaM)+(Suur.TaP*Suur.TaM):7:2); gotoxy(61,14); Write((Laps.KuP*Laps.KuM)+(Opilane.KuP*Opilane.KuM)+(Suur.KuP*Suur.KuM):7:2); gotoxy(61,16); Write((Laps.KvP*Laps.KvM)+(Opilane.KvP*Opilane.KvM)+(Suur.KvP*Suur.KvM):7:2); gotoxy(61,18); Write((Laps.TaP*Laps.TaM)+(Laps.KuP*Laps.KuM)+(Laps.KvP*Laps.KvM):7:2); gotoxy(61,20); Write((Opilane.TaP*Opilane.TaM)+(Opilane.KuP*Opilane.KuM)+(Opilane.KvP*Opilane.KvM):7:2); gotoxy(61,22); Write((Suur.TaP*Suur.TaM)+(Suur.KuP*Suur.KuM)+(Suur.KvP*Suur.Kvm):7:2); Total := (Laps.TaP*Laps.TaM)+(Opilane.TaP*Opilane.TaM)+(Suur.TaP*Suur.TaM)+ (Laps.KuP*Laps.KuM)+(Opilane.KuP*Opilane.KuM)+(Suur.KuP*Suur.KuM)+ (Laps.KvP*Laps.KvM)+(Opilane.KvP*Opilane.KvM)+(Suur.KvP*Suur.KvM); gotoxy(61,24); Write(Total:7:2); Repeat Ch := Readkey; Until Ord(Ch) = 27; mode(1,1); for TmpY := 08 to 25 do begin for TmpX := 30 to 76 do begin Gotoxy(TmpX,TmpY); Write(' '); end; end; gotoxy(02,Y); end; Procedure PiletiValik_Vali; begin if Y = 19 then Uus_Kast else if Y = 20 then Uus_Kast else if Y = 21 then Uus_Kast else if Y = 22 then Muuda_Hindu else if Y = 23 then Kokkuvotted else if Y = 24 then Begin Fclose; Lopeta; End; end; procedure Liigu(kuhu : string); begin if (kuhu = 'yles') and (y <= 19) or (kuhu = 'alla') and (y >= 24) then Exit else mode(0,14); gotoxy(02,19); Write(' Uus lapsepilet '); gotoxy(02,20); Write(' Uus pilasepilet '); gotoxy(02,21); Write(' Uus tisealisepilet '); gotoxy(02,22); Write(' Muuda hindu '); gotoxy(02,23); Write(' Kokkuvtted '); gotoxy(02,24); Write(' Lahkuda DOS-i '); mode(4,14); if kuhu = 'yles' then Dec(Y); if kuhu = 'alla' then Inc(Y); gotoxy(02, y); if Y = 19 then s := ' Uus lapsepilet ' else if Y = 20 then s := ' Uus pilasepilet ' else if Y = 21 then s := ' Uus tisealisepilet ' else if Y = 22 then s := ' Muuda hindu ' else if Y = 23 then s := ' Kokkuvtted ' else if Y = 24 then s := ' Lahkuda DOS-i '; Write(s); end; procedure mainmenu; begin FOpen; kaota_kursor; Mode(01,15); Clrscr; mode(00,07); gotoxy(1,01); Write('ͻ'); gotoxy(1,02); Write(' Tere tulemast LOOMAAIA PILETIKASSASSE! '); gotoxy(1,03); Write('ͼ'); mode(00,10); gotoxy(23,02);Writeln(' Tere tulemast LOOMAAIA PILETIKASSASSE!') ; mode(04,14); gotoxy(2,04); Write('ͻ'); gotoxy(2,05); Write(' Valikut saate teha, liikudes mens nooleklahvidega sobivale kohale ja '); gotoxy(2,06); Write(' vajutades siis klahvile . Alammendest saab vlja vajutades '); gotoxy(2,07); Write('ͼ'); JoonistaKast; Gotoxy(02,19); X := WhereX; Y := WhereY; Repeat C := ReadKey; if ord(c)=0 then begin D := ReadKey; if ord(d) = 72 then Liigu('yles') else if ord(d) = 80 then Liigu('alla') else end else if ord(c) = 13 then PiletiValik_Vali else Until (ord(d) = 13) and (y = 24); end; BEGIN MAINMENU; END.