2.4 Листинг программы
domains
c1,c2,ch=char
x,c,n,n1,i,i1=integer
l=string*
type_spis = integer*
IDman,IDkl,IDsoor,IDs,IDv,IDtrener=integer
day,month,year,hour,minutes=integer
katsl, kol,mesta,katslozh=integer
nazv,tren,t_start,t_end,specp,nvid,trener=string
surname,nm,parname=string
name=fio(surname,nm,parname)
Data=data(day,month,year)
Time=time(hour,minutes)
database -db_sportsm
sportsm(IDman,name,katsl,type_spis,IDkl)
database -db_vid
vid(IDv,nvid,IDtrener)
database -db_klub
klub(IDkl,nazv,IDtrener,IDv)
database -db_soor
sooruzhen(IDsoor,t_start,t_end,mesta)
database -db_sorev
sorevnov(IDs,specp,IDman,IDkl,IDsoor,Data,Time,katslozh)
database -db_trener
trener(IDtrener,name,IDv)
predicates
run
load_db
showmenu
dialog
showdialog
vibor(integer)
save_db
ret
table_sports
table_sportsID
table_kl
table_klID
table_soor
table_soorID
table_sorev
table_vid
table_vIDmanD
table_trener
table_trenerID
menu_ydalenie
vibor1(integer)
ydalenie_sorev1(integer)
ydalenie_sorev2(integer)
ydalenie_sorev3(integer)
ydalenie_sorev4(integer)
ydalenie_sorev5(integer)
menu_dobavlenie
vibor2(integer)
dobavlenie(integer,integer)
proverka_sports(integer)
proverka_kl(integer)
proverka_soor(integer)
proverka_sorev(integer)
proverka_vid(integer)
proverka_trener(integer)
prov(l,string) /*+++++++++++++*/
prov2(l,integer) /*+++++++++++++*/
provID(type_spis,integer)
menu_poisk
poisk(integer)
menu_poisk_sportsmena
menu_poisk_kluba
menu_poisk_sooruzheniya
menu_poisk_sorevnovaniya
menu_poisk_vid
poisk_sportsm(integer)
poisk_klub(integer)
poisk_sooruzh(integer)
poisk_sorevn(integer)
poisk_vid(integer)
menu_zapros
zapros(integer)
print_vid(IDv,nvid,IDtrener)
print_vIDmanD(IDv,nvid,IDtrener)
print_sportsm(IDman,name,katsl,type_spis,IDkl)
print_sportsmID(IDman,name,katsl,type_spis,IDkl)
print_klub(IDkl,nazv,IDtrener,IDv)
print_klubID(IDkl,nazv,IDtrener,IDv)
print_soor(IDsoor,t_start,t_end,mesta)
print_soorID(IDsoor,t_start,t_end,mesta)
print_sorevn(IDs,specp,IDman,IDkl,IDsoor,Data,Time,katslozh)
print_sorevn1(IDs,specp,IDman,IDkl,IDsoor,Data,Time,katslozh)
print_trener(IDtrener,name,IDv)
print_trenerID(IDtrener,name,IDv)
zapros1(IDsoor)
zapros2(Surname)
zapros3(integer)
zapros5(Hour)
zapros6()
zapros7(integer)
zapros8(integer,integer)
zapros9(integer)
zapros10(string)
zapros12()
length(type_spis, integer)
print_list(type_spis)
read_list(integer,type_spis).
clauses
run:- load_db,
makewindow(1,500,500,"Glavnoe Menu",0,0,20,26),
makewindow(2,500,500,"Dialog",20,0,5,26),
makewindow(3,500,500,"Resultat",0,26,25,54),
showmenu,
dialog.
load_db:-existfile("dbs.txt"),consult("dbs.txt",db_sportsm),
existfile("dbk.txt"),consult("dbk.txt",db_klub),
existfile("dbsoor.txt"),consult("dbsoor.txt",db_soor),
existfile("dbv.txt"),consult("dbv.txt",db_vid),
existfile("dbsor.txt"),consult("dbsor.txt",db_sorev),
existfile("dbtrener.txt"),consult("dbtrener.txt",db_trener).
showmenu:-
shiftwindow(1),clearwindow,
cursor(2,1),write("1 - Spisok sportsmenov"),nl,
cursor(3,1),write("2 - Spisok klubov"),nl,
cursor(4,1),write("3 - Spisok sooruzhenij"),nl,
cursor(5,1),write("4 - Spisok sorevnovanij"),nl,
cursor(6,1),write("5 - Spisok vidov sporta"),nl,
cursor(7,1),write("6 - Spisok ternerov"),nl,
cursor(8,1),write("7 - Udalenie"),nl,
cursor(9,1),write("8 - Dobavlenie"),nl,
cursor(10,1),write("9 - Soxranenie"), nl,
cursor(11,1),write("10 - Poisk"),nl,
cursor(12,1),write("11 - Zaprosy"),nl,
cursor(13,1),write("12 - Vyxod").
dialog:-
showdialog,readint(X),
shiftwindow(3), vibor(X).
showdialog:-
shiftwindow(2),clearwindow,
cursor(1,3),write("Vvedite nomer"),nl,
cursor(2,3),write ("punkta menu -> ").
vibor(1):- not(print_sportsm(_,fio(_,_,_),_,_,_)),dialog.
vibor(2):- not(print_klub(_,_,_,_)),dialog.
vibor(3):- not(print_soor(_,_,_,_)),dialog.
vibor(4):- not(print_sorevn (_,_,_,_,_,data(_,_,_),time(_,_),_)),dialog.
vibor(5):- not(print_vid(_,_,_)),dialog.
vibor(6):- not(print_trener(_,_,_)),dialog.
vibor(7):- menu_ydalenie,dialog.
vibor(8):- menu_dobavlenie,dialog.
vibor(9):- clearwindow, save_db,dialog.
vibor(10):- menu_poisk,dialog.
vibor(11):- menu_zapros,dialog.
vibor(12):- clearwindow,write("Soxranit izmeneniya?(y/n)"),readchar(Ch),Ch='y',clearwindow,
save_db, nl, write("Dlya vyxoda nazhmite lybuyu klavishu"), readchar(_), ret,
removewindow,removewindow,removewindow;ret,
removewindow,removewindow,removewindow.
save_db:- save("dbs.txt",db_sportsm),
save("dbk.txt",db_klub),
save("dbsoor.txt",db_soor),
save("dbsor.txt",db_sorev),
save("dbv.txt",db_vid),
save("dbtrener.txt",db_trener),
write("Vse soxraneno").
ret:- retractall(_),retractall(_,db_sportsm),retractall(_,db_klub),
retractall(_,db_soor),retractall(_,db_vid),retractall(_,db_sorev),retractall(_,db_trener).
print_vid(_,Nvid,IDtrener):- table_vid,
vid(_,Nvid,IDtrener),
write("|"),writef("%13",Nvid),
trener(IDtrener,fio(Fam,Im,Otch),_),
write(" |"),writef("%8",Fam),
write(" "),writef("%8",Im),
write(" "),writef("%10",Otch),nl, fail.
table_vid:-
clearwindow,
cursor(1,17), write("VIDY SPORTA"),nl,
write("---------------------------------------------------"),nl,
write("| Vid sporta | FIO trenera |"),nl,
write("---------------------------------------------------"),nl.
/********************************************/
print_vIDmanD(IDv,Nvid,IDtrener):- table_vIDmanD,
vid(IDv,Nvid,IDtrener),
write("|"),writef("%5",IDv),
write("|"),writef("%20",Nvid),
write("|"),writef("%24",IDtrener), fail.
table_vIDmanD:-
clearwindow,
cursor(1,17), write("VIDY SPORTA"),nl,
write("----------------------------------------------------"),
write("|"," ID ","|","Nazvanie vida sporta","|"," Familiya trenera ","|"),
write("----------------------------------------------------").
/*******************************************************/
print_sportsm(IDman,fio(Surname,Nm,Parname),Katsl,Spis,IDKL):- table_sports,
sportsm(IDman,fio(Surname,Nm,Parname),Katsl,Spis,IDKL),
klub(IDKL,NAZV,_,_),
write("|"),writef("%10 ",Surname),
frontchar(Nm,C1,_),write(C1),
write("."),frontchar(Parname,C2,_),write(C2),
write(".|"),
writef("%3",Katsl),write("|"),
writef("%10",NAZV),write("|"),
print_list(Spis),nl,fail.
table_sports:-
clearwindow,
cursor(1,17), write("SPORTSMENY"),nl,
write("----------------------------------------------------"),nl,
write("|"," Name ","|","KMA","|"," Klub ","|"," Vid sporta ","|"),nl,
write("----------------------------------------------------"),nl.
/****************************************************/
print_list([]).
print_list([Head|Tail]):- vid(Head,VID,_),write(VID," "), print_list(Tail).
read_list(0,[]).
read_list(N,[Head|Tail]):- readint(Head),vid(Head,_,_),N1=N-1,read_list(N1,Tail).
/****************************************************/
print_sportsmID(IDman,fio(Surname,Nm,Parname),Katsl,Spis,IDKL):- table_sportsID,
sportsm(IDman,fio(Surname,Nm,Parname),Katsl,Spis,IDKL),
klub(IDKL,NAZV,_,_),
write("|"),writef("%3",IDman),
write("|"),writef("%9 ",Surname),
frontchar(Nm,C1,_),write(C1),
write("."),frontchar(Parname,C2,_),write(C2),
write(".|"),
writef("%2",Katsl),write("|"),
writef("%10",NAZV),write("|"),
print_list(Spis),nl,fail.
table_sportsID:-
clearwindow,
cursor(1,17), write("SPORTSMENY"),nl,
write("----------------------------------------------------"),nl,
write("|ID | Name |KM| Klub | Vid sporta |"),nl,
write("----------------------------------------------------"),nl.
/**********************************************/
print_klub(IDkl,Nazv,Tren,IDV):- table_kl,
klub(IDkl,Nazv,Tren,IDV),
write("|"),writef("%10",Nazv),
trener(Tren,fio(Fam,_,_),_),
write(" |"),writef("%10",Fam),
vid(IDV,NVID,_),
write("|"),writef("%7 ",NVID),
nl, fail.
table_kl:-
clearwindow,
cursor(1,17), write("KLUBY"),nl,
write("----------------------------------------------------"),
write("|"," Nazvanie ","|"," Trener ","|","vid sporta"),nl,
write("----------------------------------------------------").
/***********************************************************/
print_klubID(IDkl,Nazv,Tren,IDV):- table_klID,
klub(IDkl,Nazv,Tren,IDV),
write("|"),writef("%2",IDkl),
write("|"),writef("%10",Nazv),
write(" |"),writef("%12",Tren),
vid(IDV,NVID,_),
write("|"),writef("%7 ",NVID),
nl, fail.
table_klID:-
clearwindow,
cursor(1,17), write("KLUBY"),nl,
write("----------------------------------------------------"),
write("|","ID","|"," Nazvanie ","|","Administratr","|","vid sporta"),nl,
write("----------------------------------------------------").
/****************************************************/
print_soorID(IDsoor,T_start,T_end,Mesta):- table_soorID,
sooruzhen(IDsoor,T_start,T_end,Mesta),
write("|"),writef("%5",IDsoor),
write("|"),writef("%10 ",T_start),
write(" |"),writef("%14",T_end),
write(" |"),writef("%10",Mesta), nl, fail.
table_soorID:-
clearwindow,
cursor(1,17), write("SOORUZHENIYA"),nl,
write("----------------------------------------------------"),
write("|"," ID ","|"," Nazvanie ","|"," Pokrytie ","|","Kol-vo mest","|"),
write("----------------------------------------------------").
/*****************************************************/
print_soor(IDsoor,T_start,T_end,Mesta):- table_soor,
sooruzhen(IDsoor,T_start,T_end,Mesta),
/*write("|"),writef("%5",IDsoor),*/
write("|"),writef("%10 ",T_start),
write(" |"),writef("%14",T_end),
write(" |"),writef("%10",Mesta), nl, fail.
table_soor:-
clearwindow,
cursor(1,17), write("SOORUZHENIYA"),nl,
write("----------------------------------------------------"),
write("|"," Nazvanie ","|"," Pokrytie ","|","Kol-vo mest ","|"),
write("----------------------------------------------------").
/**********************************************************/
print_sorevn(IDs,Specp,IDman,IDkl,IDsoor,data(Day,Month,Year),time(Hour,Minutes),Katslozh):- table_sorev,
sorevnov(IDs,Specp,IDman,IDkl,IDsoor,data(Day,Month,Year),time(Hour,Minutes),Katslozh), klub(IDkl,Nazv,_,_),
sooruzhen(IDsoor,Mesto,_,_),
write("|"),writef("%7",Specp),
write(" |"),writef("%3",Day),
write("."),writef("%2",Month),
write("."),write(Year),
write(" |"),writef("%2",Hour),
write(":"),writef("%2",Minutes),
write("|"),writef("%2",Katslozh),
write("|"),writef("%7",Mesto),
write(" |"),writef("%1",Nazv), nl, fail.
table_sorev:-
clearwindow,
cursor(1,17), write("SOREVNOVANIYA"),nl,
write("----------------------------------------------------"),
write("|","Nazvanie","|"," Data ","|"," Time","|","KS","|"," Mesto ","|","Klub"),nl,
write("----------------------------------------------------").
/************************************************************/
/********************************************/
print_trener(_,fio(Fam,Im,Otch),IDv):- table_trener,
trener(_,fio(Fam,Im,Otch),IDv),
write("| "),writef("%10",Fam),
write(" "),writef("%10",Im),
write(" "),writef("%15",Otch),
vid(IDV,Nazv,_),
write("| "),writef("%8",Nazv),nl,fail.
table_trener:-
clearwindow,
cursor(1,17), write("TRENERA"),nl,
write("----------------------------------------------------"),
write("|"," FIO Trenera ","|"," Vid sporta","|"),nl,
write("----------------------------------------------------"),nl.
/*********************************************/
print_trenerID(IDtren,fio(Fam,Im,Otch),IDv):- table_trenerID,
trener(IDtren,fio(Fam,Im,Otch),IDv),
write("|"),writef("%2",IDtren),
write("|"),writef("%10",Fam),
write(""),writef("%10",Im),
write(" "),writef("%15",Otch),
vid(IDV,Nazv,_),
write("|"),writef("%8",Nazv),nl,fail.
table_trenerID:-
clearwindow,
cursor(1,17), write("TRENERA"),nl,
write("----------------------------------------------------"),
write("|ID| FIO Trenera |Vid sporta"),nl,
write("----------------------------------------------------"),nl.
/*********************************************/
menu_ydalenie:- clearwindow,
cursor(2,1),write("1 - sportsmena"),nl,
cursor(3,1),write("2 - kluba"),nl,
cursor(4,1),write("3 - sooruzheniya"),nl,
cursor(5,1),write("4 - sorevnovaniya"),nl,
cursor(6,1),write("5 - vida sporta"),nl,
cursor(7,1),write("6 - trenera"),nl,
cursor(8,1),write("7 - vozvrat v glavnoe menu"),nl,nl,
cursor(10,1),write("Vvedite punkt menu ->"),readint(C),
C>=1,C<=7,!,vibor1(C);vibor1(7).
vibor1(1):-
not(print_sportsmID(_,fio(_,_,_),_,_,_)),nl,
write(" Vvedite nomer ydalyaemogo sportsmena: "), readint(IDman),nl,
sportsm(IDman,fio(_,_,_),_,_,_),!,
retract(sportsm(IDman,fio(_,_,_),_,_,_)),
not(ydalenie_sorev1(IDman)),
write("Dannie ydaleni!!!") ;nl,write(" Vi oshiblis`!!! Takogo ID net!!!"),nl,vibor1(1).
vibor1(2):-
not(print_klubID(_,_,_,_)),nl,
write("Vvedite nomer ydalyaemogo kluba: "), readint(IDkl),nl,
klub(IDkl,_,_,_),!,
retract(klub(IDkl,_,_,_)),
not(ydalenie_sorev2(IDkl)),
write("Dannie ydaleni!!!");nl,write(" Vi oshiblis`!!! Takogo ID net!!!"),nl,vibor1(2).
vibor1(3):-
not(print_soorID(_,_,_,_)),nl,
write("Vvedite nomer ydalyaemogo sooruzheniya: "), readint(IDsoor),nl,
sooruzhen(IDsoor,_,_,_),!,
retract(sooruzhen(IDsoor,_,_,_)),
not(ydalenie_sorev3(IDsoor)),
write("Dannie ydaleni!!!");nl,write(" Vi oshiblis`!!! Takogo ID net!!!"),nl,vibor1(3).
vibor1(4):-
nl,write("Vvedite nomer ydalyaemogo sorevnovaniya: "), readint(IDs),nl,
sorevnov(IDs,_,_,_,_,data(_,_,_),time(_,_),_),!,
retract(sorevnov(IDs,_,_,_,_,data(_,_,_),time(_,_),_)),
write("Dannie ydaleni!!!");nl,write(" Vi oshiblis`!!! Takogo ID net!!!"),nl,vibor1(4).
vibor1(5):-
not(print_vIDmanD(_,_,_)),nl,
write("Vvedite nomer ydalyaemogo vida sporta: "), readint(IDV),nl,
vid(IDV,_,_),
retract(vid(IDV,_,_)),
not(ydalenie_sorev4(IDV)),
not(ydalenie_sorev5(IDV)),
write("Dannie ydaleni!!!");nl,write(" Vi oshiblis`!!! Takogo ID net!!!"),nl,readchar(_),menu_ydalenie.
vibor1(6):-
not(print_trenerID(_,_,_)),
nl,write("Vvedite nomer ydalyaemogo trenera: "), readint(IDtren),nl,
trener(IDtren,_,_),!,
retract(trener(IDtren,_,_)),
write("Dannie ydaleni!!!");nl,write(" Vi oshiblis`!!! Takogo ID net!!!"),nl,vibor1(6).
vibor1(7):-clearwindow.
prov([],_).
prov([H|T],Vid):-H=Vid,prov(T,Vid),!.
prov([_|T],Vid):-prov(T,Vid).
provID([H|T],ID):-H=ID,!;provID(T,ID).
/********************************************/
ydalenie_sorev1(IDman):- retract(sorevnov(_,_,IDman,_,_,data(_,_,_),time(_,_),_)), fail.
ydalenie_sorev2(IDkl):- retract(sportsm(_,fio(_,_,_),_,_,IDkl)), fail.
ydalenie_sorev4(IDV):-sportsm(ID,_,_,Spis,_),provID(Spis,IDV),retract(sportsm(ID,_,_,_,_)),write("asd"), fail.
ydalenie_sorev5(IDV):- retract(klub(IDk,_,_,IDV)),retract(sportsm(_,fio(_,_,_),_,_,IDk)), fail.
ydalenie_sorev3(IDsoor):- retract(sorevnov(_,_,_,_,IDsoor,data(_,_,_),time(_,_),_)), fail.
menu_dobavlenie:-
clearwindow,
cursor(2,1),write("1 - dobavlenie sportsmena"),nl,
cursor(3,1),write("2 - dobavlenie kluba"),nl,
cursor(4,1),write("3 - dobavlenie sooruzheniya"),nl,
cursor(5,1),write("4 - dobavlenie sorevnovaniya"),nl,
cursor(6,1),write("5 - dobavlenie vida sporta"),nl,
cursor(7,1),write("6 - dobavlenie trenera"),nl,
cursor(8,1),write("7 - vozvrat v glavnoe menu"),nl,nl,
cursor(10,1),write("Vvedite punkt menu -> "), readint(C),
C>=1,C<=7,!,vibor2(C);vibor2(7).
vibor2(1):-
clearwindow,
not(print_sportsmID(_,fio(_,_,_),_,_,_)),nl,
write("Vvedite nomer: "), readint(IDman),proverka_sports(IDman).
vibor2(2):-
clearwindow,
not(print_klubID(_,_,_,_)),nl,
write("Vvedite nomer: "), readint(IDkl),proverka_kl(IDkl).
vibor2(3):-
clearwindow,
not(print_soorID(_,_,_,_)),nl,
write("Vvedite nomer: "), readint(IDsoor),proverka_soor(IDsoor).
vibor2(4):-
clearwindow,
write("Vvedite nomer: "), readint(IDs),proverka_sorev(IDs).
vibor2(5):-
clearwindow,
not(print_vIDmanD(_,_,_)),nl,
write("Vvedite nomer: "), readint(IDv),proverka_vid(IDv).
vibor2(6):-
clearwindow,
not(print_trenerID(_,_,_)),nl,
write("Vvedite ID: "), readint(IDtren),proverka_trener(IDtren).
vibor2(7):-clearwindow.
proverka_sports(IDman):-sportsm(IDman,fio(_,_,_),_,_,_),!,nl,
write("Yzhe syschestvyet zapis s takoj ID!!!"),nl,
write("Nazhmite lyubyyu klavishy"),readchar(_),vibor2(1);dobavlenie(1,IDman).
proverka_kl(IDkl):-klub(IDkl,_,_,_),!,nl,
write("Yzhe syschestvyet zapis s takoj ID!!!"),nl,
write("Nazhmite lyubyyu klavishy"),readchar(_),vibor2(2);dobavlenie(2,IDkl).
proverka_soor(IDsoor):-sooruzhen(IDsoor,_,_,_),!,nl,
write("Yzhe syschestvyet zapis s takoj ID!!!"),nl,
write("Nazhmite lyubyyu klavishy"),readchar(_),vibor2(3);dobavlenie(3,IDsoor).
proverka_sorev(IDs):-sorevnov(IDs,_,_,_,_,data(_,_,_),time(_,_),_),!,nl,
write("Yzhe syschestvyet zapis s takoj ID!!!"),nl,
write("Nazhmite lyubyyu klavishy"),readchar(_),vibor2(4);dobavlenie(4,IDs).
proverka_vid(IDv):-vid(IDv,_,_),!,nl,
write("Yzhe syschestvyet zapis s takoj ID!!!"),nl,
write("Nazhmite lyubyyu klavishy"),readchar(_),vibor2(5);
dobavlenie(5,IDv).
proverka_trener(IDtren):-trener(IDtren,_,_),!,nl,
write("Yzhe syschestvyet zapis s takoj ID!!!"),nl,
write("Nazhmite lyubyyu klavishy"),readchar(_),vibor2(6);
dobavlenie(6,IDtren).
dobavlenie(1,IDman):- nl,
write("Vvedite Familiyu: "), readln(Surname), nl,
write("Vvedite Imya: "), readln(Nm), nl,
write("Vvedite Otchestvo: "), readln(Parname), nl,
write("Vvedite KatSlozh: "), readint(Katsl), nl,
write("Vvedite kolichestvo vidov sporta : "),readint(Kol),nl,
not(print_vIDmanD(_,_,_)),nl,
write("Vvedite ID vida : "),nl,
read_list(Kol,Spis),
not(print_klubID(_,_,_,_)),
write("Vvedite ID kluba: "),
readint(IDkl),
klub(IDkl,_,_,_),
assertz(sportsm(IDman,fio(Surname,Nm,Parname),Katsl,Spis,IDkl),db_sportsm),
write("Dannie dobavleni!!!").
dobavlenie(2,IDkl):-
write("Vvedite nazvanie: "), readln(Nazv),nl,
not(print_trenerID(_,_,_)),
write("Vvedite ID trenera: "), readint(Tren), nl,
trener(Tren,_,_),
not(print_vIDmanD(_,_,_)),nl,
write("Vvedite ID vida : "),nl,
readint(IDV),
vid(IDV,_,_),
assertz(klub(IDkl,Nazv,Tren,IDV),db_klub),
write("Dannie dobavleni!!!").
dobavlenie(3,IDsoor):-
write("Vvedite nazvanie sooruzheniya: "), readln(T_start), nl,
write("Vvedite pokrytie: "), readln(T_end), nl,
write("Vvedite kolichestvo mest: "), readint(Mesta), nl,
assertz(sooruzhen(IDsoor,T_start,T_end,Mesta),db_soor),
write("Dannie dobavleni!!!").
dobavlenie(4,IDs):-
write("Vvedite nazvaniye: "), readln(Specp), nl,
not(print_sportsmID(_,fio(_,_,_),_,_,_)),nl,
write("Vvedite nomer sportsmena: "), readint(IDman), nl,
not(print_klubID(_,_,_,_)),nl,
write("Vvedite nomer kluba: "), readint(IDkl), nl,
not(print_soorID(_,_,_,_)),nl,
write("Vvedite nomer sooruzheniya: "), readint(IDsoor), nl,
write("Vvedite den sorevnovaniya: "), readint(Day), nl,
write("Vvedite mesyac sorevnovaniya: "), readint(Month), nl,
write("Vvedite god sorevnovaniya: "), readint(Year), nl,
write("Vvedite vremya nachala sorevnovaniya(chasy): "), readint(Hour), nl,
write("Vvedite vremya nachala sorevnovaniya(minuti): "), readint(Minutes), nl,
write("Vvedite kategoriyu slozhnosti sorevnovaniya: "), readint(Katslozh), nl,
assertz(sorevnov(IDs,Specp,IDman,IDkl,IDsoor,data(Day,Month,Year),time(Hour,Minutes),Katslozh),db_sorev),
write("Dannie dobavleni!!!").
dobavlenie(5,IDv):-
not(print_vid(_,_,_)),nl,
write("Vvedite nazvanie vida sporta: "), readln(Nvid),nl,
not(print_vid(_,_,_)),nl,
not(print_trenerID(_,_,_)),nl,
write("Vvedite ID trenera: "), readint(IDtre), nl,
assertz(vid(IDv,Nvid,IDtre),db_vid),
write("Dannie dobavleni!!!").
dobavlenie(6,IDtren):-
write("Vvedite failiju trenere: "), readln(Fam),nl,
write("Vvedite imia trenere: "), readln(Im),nl,
write("Vvedite otchestvo trenere: "), readln(Otch),nl,
not(print_vIDmanD(_,_,_)),nl,
write("Vvedite ID vida sporta: "), readint(IDvid), nl,
assertz(trener(IDtren,fio(Fam,Im,Otch),IDvid),db_trener),
write("Dannie dobavleni!!!").
menu_poisk:-
clearwindow,
cursor(2,1),write("1 - poisk sportsmena"),nl,
cursor(3,1),write("2 - poisk kluba"),nl,
cursor(4,1),write("3 - poisk sooruzheniya"),nl,
cursor(5,1),write("4 - poisk sorevnovaniya"),nl,nl,
cursor(6,1),write("5 - poisk vida sporta"),nl,nl,
cursor(7,1),write("6 - vozvrat v glavnoe menu"),nl,nl,
cursor(9,1),write("Vvedite punkt menu -> "), readint(C),
C>=1, C<=6,!,clearwindow,poisk(C);poisk(6).
menu_poisk:-menu_poisk.
poisk(1):-menu_poisk_sportsmena.
poisk(2):-menu_poisk_kluba.
poisk(3):-menu_poisk_sooruzheniya.
poisk(4):-menu_poisk_sorevnovaniya.
poisk(5):-menu_poisk_vid.
poisk(6):-clearwindow,dialog.
menu_poisk_sportsmena:-
clearwindow,
cursor(2,1),write("1 - poisk po ID"),nl,
cursor(3,1),write("2 - poisk po familii"),nl,
cursor(4,1),write("3 - poisk po imeni"),nl,
cursor(5,1),write("4 - poisk po otchestvy"),nl,
cursor(6,1),write("5 - poisk po kategorii slozhnojsti"),nl,
cursor(7,1),write("6 - vozvrat v glavnoe menu"),nl,
cursor(9,1),write("Vvedite punkt menu -> "), readint(C),C>=1,
C<=6,!,clearwindow,poisk_sportsm(C);poisk_sportsm(6).
poisk_sportsm(1):-cursor(3,1),write("Vvedite ID sportsmena: "),readint(IDman),
not(print_sportsm(IDman,fio(_,_,_),_,_,_)).
poisk_sportsm(2):-cursor(3,1),write("Vvedite familiyu sportsmena: "),readln(Surname),
not(print_sportsm(_,fio(Surname,_,_),_,_,_)).
poisk_sportsm(3):-cursor(3,1),write("Vvedite imya sportsmena: "),readln(Nm),
not(print_sportsm(_,fio(_,Nm,_),_,_,_)).
poisk_sportsm(4):-cursor(3,1),write("Vvedite otchestvo sportsmena: "),readln(Parname),
not(print_sportsm(_,fio(_,_,Parname),_,_,_)).
poisk_sportsm(5):-cursor(3,1),write("Vvedite kategoriyu slozhnosti sportsmena: "),readint(Katsl),
not(print_sportsm(_,fio(_,_,_),Katsl,_,_)).
poisk_sportsm(6):-clearwindow,dialog.
menu_poisk_vid:-
clearwindow,
cursor(2,1),write("1 - poisk po ID"),nl,
cursor(3,1),write("2 - poisk po nazvaniyu"),nl,
cursor(4,1),write("3 - poisk po treneru"),nl,
cursor(5,1),write("4 - vozvrat v glavnoe menu"),nl,
cursor(9,1),write("Vvedite punkt menu -> "), readint(C),C>=1,
C<=6,!,clearwindow,poisk_vid(C);poisk_vid(4).
poisk_vid(1):-cursor(3,1),write("Vvedite ID vida: "),readint(IDv),
not(print_vid(IDv,_,_)).
poisk_vid(2):-cursor(3,1),write("Vvedite nazvanie vida: "),readln(Nvid),
not(print_vid(_,Nvid,_)).
poisk_vid(3):-cursor(3,1),write("Vvedite familiju trenera: "),readln(Trener),trener(IDtrener,fio(Trener,_,_),_),
not(print_vid(_,_,IDtrener)).
poisk_vid(4):-clearwindow,dialog.
menu_poisk_kluba:-
clearwindow,
cursor(2,1),write("1 - poisk po ID"),nl,
cursor(3,1),write("2 - poisk po nazvaniyu"),nl,
cursor(4,1),write("3 - poisk po specializacii"),nl,nl,
cursor(5,1),write("4 - vozvrat v glavnoe menu"),nl,
cursor(8,1),write("Vvedite punkt menu -> "), readint(C),C>=1,
C<=4,!,clearwindow,poisk_klub(C);poisk_klub(4).
poisk_klub(1):-cursor(3,1),write("Vvedite ID kluba: "),readint(IDkl),
not(print_klub(IDkl,_,_,_)).
poisk_klub(2):-cursor(3,1),write("Vvedite nazvanie kluba: "),readln(Nazv),
not(print_klub(_,Nazv,_,_)).
poisk_klub(3):-cursor(3,1),write("Vvedite familiju trenera kluba: "),readln(Tren),trener(IDtrener,fio(Tren,_,_),_),
not(print_klub(_,_,IDtrener,_)).
poisk_klub(4):-clearwindow,dialog.
menu_poisk_sooruzheniya:-
clearwindow,
cursor(2,1),write("1 - poisk po ID"),nl,
cursor(3,1),write("2 - poisk po nazvaniyu sooruzheniya"),nl,
cursor(4,1),write("3 - poisk po pokrytiyu sooruzheniya"),nl,
cursor(5,1),write("4 - poisk po vmestitel'nosti"),nl,nl,
cursor(6,1),write("5 - vozvrat v glavnoe menu"),nl,
cursor(9,1),write("Vvedite punkt menu -> "), readint(C),C>=1,
C<=5,!,clearwindow,poisk_sooruzh(C);poisk_sooruzh(5).
poisk_sooruzh(1):-cursor(3,1),write("Vvedite ID sooruzheniya: "),readint(IDsoor),
not(print_soor(IDsoor,_,_,_)).
poisk_sooruzh(2):-cursor(3,1),write("Vvedite nazvanie sooruzheniya: "),readln(T_start),
not(print_soor(_,T_start,_,_)).
poisk_sooruzh(3):-cursor(3,1),write("Vvedite pokrytie sooruzheniya: "),readln(T_end),
not(print_soor(_,_,T_end,_)).
poisk_sooruzh(4):-cursor(3,1),write("Vvedite vmestitel'nosti sooruzheniya: "),readint(Mesta),
not(print_soor(_,_,_,Mesta)).
poisk_sooruzh(5):-clearwindow,dialog.
menu_poisk_sorevnovaniya:- clearwindow,
cursor(2,1),write("1 - poisk po ID"),nl,
cursor(3,1),write("2 - poisk po nazvaniiu"),nl,
cursor(4,1),write("3 - poisk po ID sportsmena"),nl,
cursor(5,1),write("4 - poisk po ID kluba"),nl,
cursor(6,1),write("5 - poisk po ID sooruzheniya"),nl,
cursor(7,1),write("6 - poisk po date sorevnovaniya"),nl,
cursor(8,1),write("7 - poisk po vremeni sorevnovaniya"),nl,
cursor(9,1),write("8 - poisk po kategorii slozhnosti"),nl,
cursor(10,1),write("9 - vozvrat v glavnoe menu"),nl,
cursor(12,1),write("Vvedite punkt menu -> "), readint(C),C>=1,
C<=9,!,clearwindow,poisk_sorevn(C);poisk_sorevn(9).
poisk_sorevn(1):-cursor(3,1),write("Vvedite ID sorevnovaniya: "),readint(IDs),
not(print_sorevn1 (IDs,_,_,_,_,data(_,_,_),time(_,_),_)).
poisk_sorevn(2):-cursor(3,1),write("Vvedite nazvanie sorevnovaniya: "),readln(Specp),
not(print_sorevn1 (_,Specp,_,_,_,data(_,_,_),time(_,_),_)).
poisk_sorevn(3):-cursor(3,1),write("Vvedite ID sportsmena: "),readint(IDman),
not(print_sorevn1 (_,_,IDman,_,_,data(_,_,_),time(_,_),_)).
poisk_sorevn(4):-cursor(3,1),write("Vvedite ID kluba: "),readint(IDkl),
not(print_sorevn1 (_,_,_,IDkl,_,data(_,_,_),time(_,_),_)).
poisk_sorevn(5):-cursor(3,1),write("Vvedite ID sooruzheniya: "),readint(IDsoor),
not(print_sorevn1(_,_,_,_,IDsoor,data(_,_,_),time(_,_),_)).
poisk_sorevn(6):-cursor(3,1),write("Vvedite den : "),readint(Day),
cursor(4,1),write("Vvedite mesyac(1-12) : "),readint(Month),
cursor(5,1),write("Vvedite god : "),readint(Year),
not(print_sorevn1 (_,_,_,_,_,data(Day,Month,Year),time(_,_),_)).
poisk_sorevn(7):-cursor(3,1),write("Vvedite chasy : "),readint(Hour),
cursor(4,1),write("Vvedite minuti : "),readint(Minutes),
not(print_sorevn1 (_,_,_,_,_,data(_,_,_),time(Hour,Minutes),_)).
poisk_sorevn(8):-cursor(3,1),write("Vvedite kategoriyu slozhnjsti : "),readint(Katslozh),
not(print_sorevn1 (_,_,_,_,_,data(_,_,_),time(_,_),Katslozh)).
poisk_sorevn(9):-clearwindow,dialog.
print_sorevn1(IDs,Specp,IDman,IDkl,IDsoor,data(Day,Month,Year),time(Hour,Minutes),Katslozh):-
sorevnov(IDs,Specp,IDman,IDkl,IDsoor,data(Day,Month,Year),time(Hour,Minutes),Katslozh),
sportsm(IDman,fio(Surname,Nm,Parname),Katsl,IDV,IDkl),
klub(IDkl,Nazv,Tren,Nvid),
sooruzhen(IDsoor,T_start,T_end,Mesta),
clearwindow,
writef("%25","Nomer sorevnovaniya"),writef("%12",IDs),nl,
writef("%25","Specializaciya sorevnovaniya"),writef("%12 ",Specp),nl,
writef("%25","Nomer sportsmena"),writef("%12",IDman),nl,
writef("%25","Familiya sportsmena"),writef("%12 ",Surname),nl,
writef("%25","Nomer kluba"),writef("%12",IDkl), nl,
writef("%25","Nazvanie kluba"),writef("%12",Nazv), nl,
writef("%25","Nomer sooruzheniya"),writef("%12",IDsoor),nl,
writef("%25","Nazvanie sooruzheniya"),writef("%12",T_start),nl,
writef("%25","Pokrytie sooruzheniya"),writef("%12",T_end),nl,
writef("%25","Vmestitel'nost' sooruzheniya"),writef("%12 ",Mesta),nl,
writef("%25","Data nachala sorevnovaniya"),writef("%4",Day),write("."),writef("%2",Month),write("."),writef("%4",Year),nl,
writef("%25","Vremya nachala sorevnovaniya"),writef("%9",Hour),write(":"),writef("%2",Minutes),nl,
writef("%25","Kategoriya slozhnjsti poxoda"),writef("%12",Katslozh),nl,nl,
write("------------------------------------------------"),nl,
write(" Dlya prosmotra sledyuschej zapisi ili vixoda v "),nl,
write(" glavnoe menu nazhmite lyubyyu klavishy"),
readchar(_),clearwindow,fail;
sorevnov(IDs,Specp,IDman,IDkl,IDsoor,data(Day,Month,Year),time(Hour,Minutes),Katslozh),dialog.
menu_zapros:- clearwindow,
cursor(2,1),write("1 - Vse kluby, pobyvavshie v ukazannom sooruzhenii"),nl,
cursor(3,1),write("2 - Vse sooruzheniya, v kotoryx pobyval sportsmen v sorevnovaniyah"),nl,
cursor(4,1),write("3 - Sooruzheniya bol'she ukazannogo chisla mest"),nl,
cursor(5,1),write("4 - Vse sorevnovaniya ran'she ukaz.vremeni"),nl,
cursor(6,1),write("5 - Kolichestvo, sportsmenov sostoyashih v"),nl,
cursor(7,1),write(" ukazannom klube"),nl,
cursor(8,1),write("6 - Vse sooruzheniya,poseschennye ykaz. klubom"),nl,
cursor(9,1),write("7 - vse Kluby, uch. v sorevn.v ykaz. mes. i gody"),nl,
cursor(10,1),write("8 - Sportsmeny s ykazannoj kat. slozhnosti(1-5)"),nl,
cursor(11,1),write("9 - Specializaciya ykazannogo sportsmena"),nl,
cursor(12,1),write("10 - Kolichestvo sportsmenov dannogo vida sporta"),nl,
cursor(13,1),write("11 - Vozvrat v glavnoe menu"),nl,
cursor(16,1),write("Vvedite punkt menu -> "), readint(C),C>=1,
C<=11,!,clearwindow,zapros(C);zapros(11).
zapros(1):- clearwindow,
not(print_soorID(_,_,_,_)),nl,
write("Vvedite ID sooruzheniya: "), readint(IDsoor),table_kl,
zapros1(IDsoor).
zapros(2):- clearwindow,
not(print_sportsmID(_,fio(_,_,_),_,_,_)),nl,
write("Vvedite familiyu sportsmena: "), readln(Surname),table_soor,
zapros2(Surname).
zapros(3):- clearwindow,
write("Vvedite vmestitel'nost': "), readint(Mesta),table_soor,
zapros3(Mesta).
zapros(4):- clearwindow,
write("Vvedite chasi: "), readint(Hour),table_sorev,
zapros5(Hour).
zapros(5):- clearwindow,
not(print_klub(_,_,_,_)),
zapros6().
zapros(6):- clearwindow,
not(print_klubID(_,_,_,_)),
write("Vvedite ID kluba: "), readint(IDkl),table_soor,
zapros7(IDkl).
zapros(7):- clearwindow,
write("Vvedite mesyac(1-12) : "), readint(Month), nl,
write("Vvedite god : "), readint(Year),table_kl,
zapros8(Month,Year).
zapros(8):- clearwindow,
write("Vvedite kategoriu slozhnosti: "), readint(Katsl),
zapros9(Katsl).
zapros(9):- clearwindow,
write("Vvedite familiyu sportsmena: "), readln(Surname),
zapros10(Surname).
zapros(10):- clearwindow,not(print_vid(_,_,_)),
zapros12();
nl,
readchar(_),
menu_zapros.
zapros(11).
zapros1(IDsoor):-
sorevnov(IDs,Specp,IDman,IDkl,IDsoor,data(Day,Month,Year),time(Hour,Minutes),Katslozh),
klub(IDkl,Nazv,Tren,IDV),
/*write("|"),writef("%5",IDkl),*/
write("|"),writef("%7",Nazv),
write(" |"),writef("%15",Tren),
vid(IDV,NVID,_),
write("|"),writef("%7 ",NVID),nl, fail;zapros(11).
zapros2(Surname):-
sportsm(IDman,fio(Surname,Nm,Parname),Katsl,IDV,IDkl),
sorevnov(IDs,Specp,IDman,IDkl,IDsoor,data(Day,Month,Year),time(Hour,Minutes),Katslozh),
sooruzhen(IDsoor,T_start,T_end,Mesta),
/*write("|"),writef("%5",IDsoor),*/
write("|"),writef("%10 ",T_start),
write(" |"),writef("%14",T_end),
write(" |"),writef("%10",Mesta), nl, fail;zapros(11).
zapros3(M):- sooruzhen(IDsoor,T_start,T_end,Mesta),M
/*write("|"),writef("%5",IDsoor),*/
write("|"),writef("%10 ",T_start),
write(" |"),writef("%14",T_end),
write(" |"),writef("%10",Mesta),nl,fail;zapros(11).
zapros5(H):-
sorevnov(IDs,Specp,IDman,IDkl,IDsoor,data(Day,Month,Year),time(Hour,Minutes),Katslozh),
H>Hour,
/*write("|"),writef("%4",IDs),*/
write("|"),writef("%8 ",Specp),
/*write("|"),writef("%5",IDman),*/
/*write("|"),writef("%4",IDkl),*/
/*write("|"),writef("%4",IDsoor),*/
write(" |"),writef("%3",Day),
write("."),writef("%2",Month),
write("."),writef("%4",Year),
write(" |"),writef("%2",Hour),
write(":"),writef("%2",Minutes),
write(" |"),writef("%2",Katslozh),nl, fail;zapros(11).
zapros6():-
write("Vvedite nazvanie kluba "),
readln(NAZV),
klub(ID,NAZV,_,_),
sportsm(_,_,_,_,ID),
findall(X,sportsm(X,_,_,_,ID), Spis1),
length(Spis1, Tmp),
write("Kolichestvo sportsmenov : ",Tmp),nl;write("Net takogo nazvanija"),readchar(_),menu_zapros.
zapros7(IDkl):-
klub(IDkl,Nazv,Tren,Nvid),
sorevnov(IDs,Specp,IDman,IDkl,IDsoor,data(Day,Month,Year),time(Hour,Minutes),Katslozh),
sooruzhen(IDsoor,T_start,T_end,Mesta),
/*write("|"),writef("%5",IDsoor),*/
write("|"),writef("%10 ",T_start),
write(" |"),writef("%14",T_end),
write(" |"),writef("%10",Mesta), nl, fail;zapros(11).
zapros8(Month,Year):-
sorevnov(IDs,Specp,IDman,IDkl,IDsoor,data(Day,Month,Year),time(Hour,Minutes),Katslozh),
klub(IDkl,Nazv,Tren,Nvid),
/* write("|"),writef("%5",IDkl),*/
write("|"),writef("%10",Nazv),
write(" |"),writef("%18",Tren),nl, fail;zapros(11).
zapros9(Katsl):- not(print_sportsm(_,fio(_,_,_),Katsl,_,_)).
zapros10(Surname):- not(print_sportsm(_,fio(Surname,_,_),_,_,_)).
/*zapros11():-
sportsm(_,fio(Fam,IM,Otch),_,IDV,_),
prov2(L,N),
N>1,
write(Fam," "),write(IM," "),write(Otch," "),nl.*/
prov2([], Tmp):-Tmp = 0.
prov2([_|TX], Tmp):- prov2(TX, Tmp1), Tmp = Tmp1+1.
zapros12():-
not(print_vIDmanD(_,_,_)),nl,
write("Vvedite ID vida sporta: "),
readint(Vid),
vid(Vid,_,_),
sportsm(_,fio(Fam,_,_),_,Spis,_),
provID(Spis,Vid),
write(Fam),nl,fail.
length([], Tmp):-Tmp = 0.
length([_|TX], Tmp):- length(TX, Tmp1), Tmp = Tmp1+1.
goal run
|