. , , ,

,,,

- " " — ,

code=9000

include "tdoms.pro"

include "tpreds.pro"

include "menu.pro"

domains

i,z,n,dvig,god,n1,shasi=integer

j,mark,znac,fam,ima,otc,ucet=string

intList=integer*

strList=symbol*

charList=char*

database

avto(i,j,i,i,i,j,j,j,j,j)

predicates

/* p */

nachalo

/* */

mainmenu

/* p */

zagruz

/* p */

choice1(i)

correct(i,i)

/* p p */

rabota(i)

/* p */

savebase(i)

/* p */

loadbase(i)

/* p p */

print(i,i)

output(i)

output1(i,j,j,j)

/* max */

maxelem(intList, i)

/* p ( p pp) */

str_write(string)

/* */

strIndex(STRINGLIST, i, j)

intIndex(intList, i, i)

/* p p */

intList2strList(intList, STRINGLIST)

goal

nachalo.

clauses

/* */

nachalo:-

makewindow(1,7,23," ",0,0,25,80),

clearwindow,zagruz,

mainmenu.

/* */

mainmenu:-

menu(5,28,7,23,[" pp ", " ",

" pp ", " p ",

" p ", " ",

" ", " pp ",

" pp "], " ", 1, Vibor),

clearwindow,

rabota(Vibor),

clearwindow,

Vibor = 9,

retractall(_),

removewindow.

/* , */

zagruz:-

existfile("avto.dat"),

consult("avto.dat"),

cursor(2,20),

write(" . ..."),

readchar(_), clearwindow.

zagruz:-

cursor(2,20),

write(" . ..."),

readchar(_), clearwindow.

/* pp */

rabota(1):-

makewindow(21,48,90," pp ",0,0,25,80),

nl,

choice1(N),

avto(N,MARK,GOD,DVIG,SHASI,ZNAC,FAM,IMA,OTC,UCET),

write(" : "),write(N),nl,nl,

write(" : "),str_write(MARK),readln(MARK1),nl,

write(" : "),str_int(GODstr,GOD),str_write(GODstr),

readint(GOD1),nl,

write(" N ߠ : "),str_int(DVIGstr,DVIG),str_write(DVIGstr),

readint(DVIG1),nl,

write(" N Ƞ : "),str_int(SHASIstr,SHASI),str_write(SHASIstr),

readint(SHASI1),nl,

write(" : "),str_write(ZNAC),readln(ZNAC1),nl,

write(" ߠ : "),str_write(FAM),readln(FAM1),nl,

write(" ߠ : "),str_write(IMA),readln(IMA1),nl,

write(" Π : "),str_write(OTC),readln(OTC1),nl,

write(" : "),str_write(UCET),readln(UCET1),nl,nl,

retract(avto(N,MARK,GOD,DVIG,SHASI,ZNAC,FAM,IMA,OTC,UCET)),

assert(avto(N,MARK1,GOD1,DVIG1,SHASI1,ZNAC1,FAM1,IMA1,OTC1,UCET1)),

removewindow,

mainmenu.

/* */

rabota(2):-

makewindow(2,7,94," ",0,0,25,80),

nl,

choice1(N),

X=N,

avto(X,MARK,GOD,DVIG,SHASI,ZNAC,FAM,IMA,OTC,UCET),

retract(avto(X,MARK,GOD,DVIG,SHASI,ZNAC,FAM,IMA,OTC,UCET)),

removewindow,

mainmenu.

/* */

rabota(3):-

makewindow(3,7,79," p ",0,0,25,80),

nl, output(_),

write(" ... "),

readchar(_),

removewindow,

mainmenu.

/* */

rabota(4):-

nl,

makewindow(4,15,2," ",0,0,25,80),

menu(5,15,7,23,[" ",

" avto.dat ",

" "], " p ", 2, C),

loadbase(C),

removewindow,

mainmenu.

/* */

rabota(5):-

nl,

makewindow(5,15,2," ",0,0,25,80),

menu(5,15,7,23,[" ",

" avto.dat ",

" "], " p ", 2, I),

savebase(I),

removewindow,

mainmenu.

/* */

rabota(6):-

makewindow(7,26,48," ",0,0,25,80), nl,

findall(Numb, avto(Numb,_,_,_,_,_,_,_,_,_), List),

maxelem(List, Elem),

write(" Р : "),K=Elem+1,write(K),nl,nl,

write(" Ӡ : "),readln(F),nl,

write(" : "),readint(Y),nl,

write(" N ߠ : "),readint(J),nl,

write(" N Ƞ : "),readint(G),nl,

write(" : "),readln(W),nl,

write(" ޠ : "),readln(B),nl,

write(" ߠ : "),readln(C),nl,

write(" Π : "),readln(D),nl,

write(" : "),readln(R),nl,

N1=K,MARK1=F,GOD1=Y,DVIG1=J,SHASI1=G,ZNAC1=W,

FAM1=B,IMA1=C,OTC1=D,UCET1=R,

assertz(avto(N1,MARK1,GOD1,DVIG1,SHASI1,ZNAC1,FAM1,IMA1,OTC1,UCET1)),

removewindow, mainmenu.

/* */

rabota(7):-

makewindow(7,113,94," ",0,0,25,80),

menu(3,28,7,23,[" ", " p ",

" p ", " p ", " p ",

" ", " ", " ",

" p ", " "], " ", 1, Vibor),

correct(Vibor,N),

print(Vibor,N),

write(" ... "),

readchar(_),

removewindow,

mainmenu.

/* p pp */

rabota(9):-

makewindow(10,23,7," pp ",2,15,20,50),nl,nl,

write(" p-p "),nl,nl,

write(" "),nl,nl,

write(" : TURBO-PROLOG v.2.0. "),nl,nl,

write(" p: "),nl,nl,

write(" "),nl,nl,nl,

write(" "),

readchar(_),

removewindow,mainmenu.

rabota(_):-exit.

/* */

savebase(1):-

write(" :"),

readln(N),

save(N),

write(" "),

beep,

!.

savebase(1):-

write(" , "),

readchar(_).

savebase(2):-

save("avto.dat").

savebase(3).

/* */

loadbase(1):-

retractall(_),

write(" :"),

readln(N),

existfile(N),

consult(N),

write(" "),

beep,

!.

loadbase(1):-

nl,

write(" "),nl,

write(" "),

readchar(_).

loadbase(2):-

retractall(_),

existfile("avto.dat"),

consult("avto.dat"),

write(" "),

beep,

!.

loadbase(2):-

write(" avto.dat "),nl,

write(" "),

readchar(_).

loadbase(3).

/* */

choice1(N):-

menu(3,28,7,23,[" ", " p ",

" p ", " p ", " p ",

" "], " p ", 1, X),

correct(X,N).

correct(1,N):-

findall(Numb, avto(Numb,_,_,_,_,_,_,_,_,_), List),

intList2strList(List, NewList),

menu(3,28,7,23,NewList," ",1,Number),

intIndex(List, Number, N).

correct(2,N):-

findall(Marka, avto(_,Marka,_,_,_,_,_,_,_,_), List),

menu(3,28,7,23,List," ",1,Number),

strIndex(List, Number, Item),

avto(N,Item,_,_,_,_,_,_,_,_).

correct(3,N):-

findall(NDvig, avto(_,_,_,NDvig,_,_,_,_,_,_), List),

intList2strList(List, NewList),

menu(3,28,7,23,NewList," ",1,Number),

intIndex(List, Number, Item),

avto(N,_,_,Item,_,_,_,_,_,_).

correct(4,N):-

findall(NShas, avto(_,_,_,_,NShas,_,_,_,_,_), List),

intList2strList(List, NewList),

menu(3,28,7,23,NewList," ",1,Number),

intIndex(List, Number, Item),

avto(N,_,_,_,Item,_,_,_,_,_).

correct(5,N):-

findall(Znak, avto(_,_,_,_,_,Znak,_,_,_,_), List),

menu(3,28,7,23,List," ",1,Number),

strIndex(List, Number, Item),

avto(N,_,_,_,_,Item,_,_,_,_).

correct(6,N):-

findall(Fam, avto(_,_,_,_,_,_,Fam,_,_,_), List),

menu(3,28,7,23,List," ",1,Number),

strIndex(List, Number, Item),

avto(N,_,_,_,_,_,Item,_,_,_).

correct(7,N):-

findall(Ima, avto(_,_,_,_,_,_,_,Ima,_,_), List),

menu(3,28,7,23,List," ",1,Number),

strIndex(List, Number, Item),

avto(N,_,_,_,_,_,_,Item,_,_).

correct(8,N):-

findall(Otch, avto(_,_,_,_,_,_,_,_,Otch,_), List),

menu(3,28,7,23,List," ",1,Number),

strIndex(List, Number, Item),

avto(N,_,_,_,_,_,_,_,Item,_).

correct(9,N):-

menu(3,28,7,23,["", "p", "p", "",

""]," ",1,Number),

strIndex(["", "p", "p", "", ""], Number, Item),

avto(N,_,_,_,_,_,_,_,_,Item).

correct(10,N):-

findall(God, avto(_,_,God,_,_,_,_,_,_,_), List),

intList2strList(List, NewList),

menu(3,28,7,23,NewList," ",1,Number),

intIndex(List, Number, Item),

avto(N,_,Item,_,_,_,_,_,_,_).

/* p p */

intList2strList([], []).

intList2strList([H1|T1], [H2|T2]):-

intList2strList(T1, T2),

str_int(H2, H1).

/* */

strIndex([H|_], 1, H).

strIndex([_|R], N, Y):-strIndex(R, K, Y), N=K+1.

intIndex([H|_], 1, H).

intIndex([_|R], N, Y):-intIndex(R, K, Y), N=K+1.

/* p ( p pp) */

str_write("").

str_write(S):-

frontchar(S, H, S1),

str_write(S1),

unreadchar(H).

/* max */

maxelem([E], E).

maxelem([F|L], X):- maxelem(L, X1), X1>=F, X=X1.

maxelem([F|L], X):- maxelem(L, X1), X1

/* p p */

output(N):-

nl,

write(" ╔══════════════════════════════════════════════════════════════════════════╗"),nl,

write(" ║ ߠ ║"),nl,

write(" ╠══╦═════════╦═════╦═════╦═════╦════════╦════════════════════════╦═════════╣"),nl,

write(" ║N║ ║ ║ N ║ N ║ ║ . . . ║ ͠ ║"),nl,

write(" ║ ║║║ ║║ ʠ ║ ║ ║"),nl,

write(" ╠══╬═════════╬═════╬═════╬═════╬════════╬═══════╦════════╦═══════╬═════════╣"),nl,

avto(N,MARK,GOD,DVIG,SHASI,ZNAC,FAM,IMA,OTC,UCET),

cursor(Z,_),cursor(Z,1),write("║"),

cursor(Z,2),write(N),cursor(Z,4),write("║"),

cursor(Z,5),write(MARK),cursor(Z,14),write("║"),

cursor(Z,15),write(GOD),cursor(Z,20),write("║"),

cursor(Z,21),write(DVIG),cursor(Z,26),write("║"),

cursor(Z,27),write(SHASI),cursor(Z,32),write("║"),

cursor(Z,33),write(ZNAC),cursor(Z,41),write("║"),

cursor(Z,42),write(FAM),cursor(Z,49),write("║"),

cursor(Z,50),write(IMA),cursor(Z,58),write("║"),

cursor(Z,59),write(OTC),cursor(Z,66),write("║"),

cursor(Z,67),write(UCET),

cursor(Z,76),write("║"),

nl,

fail.

output(_):-

write(" ╚══╩═════════╩═════╩═════╩═════╩════════╩═══════╩════════╩═══════╩═════════╝"),

nl.

/* p p */

output1(GOD,IMA,OTC,UCET):-

nl,

write(" ╔══════════════════════════════════════════════════════════════════════════╗"),nl,

write(" ║ ߠ ║"),nl,

write(" ╠══╦═════════╦═════╦═════╦═════╦════════╦════════════════════════╦═════════╣"),nl,

write(" ║N║ ║ ║ N ║ N ║ ║ . . . ║ ͠ ║"),nl,

write(" ║ ║║║ ║║ ʠ ║ ║ ║"),nl,

write(" ╠══╬═════════╬═════╬═════╬═════╬════════╬═══════╦════════╦═══════╬═════════╣"),nl,

avto(N,MARK,GOD,DVIG,SHASI,ZNAC,FAM,IMA,OTC,UCET),

cursor(Z,_),cursor(Z,1),write("║"),

cursor(Z,2),write(N),cursor(Z,4),write("║"),

cursor(Z,5),write(MARK),cursor(Z,14),write("║"),

cursor(Z,15),write(GOD),cursor(Z,20),write("║"),

cursor(Z,21),write(DVIG),cursor(Z,26),write("║"),

cursor(Z,27),write(SHASI),cursor(Z,32),write("║"),

cursor(Z,33),write(ZNAC),cursor(Z,41),write("║"),

cursor(Z,42),write(FAM),cursor(Z,49),write("║"),

cursor(Z,50),write(IMA),cursor(Z,58),write("║"),

cursor(Z,59),write(OTC),cursor(Z,66),write("║"),

cursor(Z,67),write(UCET),

cursor(Z,76),write("║"),

nl,

fail.

output1(_,_,_,_):-

write(" ╚══╩═════════╩═════╩═════╩═════╩════════╩═══════╩════════╩═══════╩═════════╝"),

nl.

/* p p */

print(Vibor,N):-Vibor<7, output(N).

print(7,N):-

avto(N,_,_,_,_,_,_,IMA,_,_),

output1(_,IMA,_,_).

print(8,N):-

avto(N,_,_,_,_,_,_,_,OTC,_),

output1(_,_,OTC,_).

print(9,N):-

avto(N,_,_,_,_,_,_,_,_,UCET),

output1(_,_,_,UCET).

print(10,N):-

avto(N,_,GOD,_,_,_,_,_,_,_),

output1(GOD,_,_,_).

code=9000 include "tdoms.pro" include "tpreds.pro" include "menu.pro" domains i,z,n,dvig,god,n1,shasi=integer j,mark,znac,fam,ima,otc,ucet=string intList=integer* strList=symbol* charList=char* datab

 

 

 

! , , , .
. , :