%UPDATED: 03 APRIL 2006; FILE NAME: factsAndRules3.rfp %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -------DATA OF COMPANY A: db1(Name, Location, TelephoneNumber, NameOfLeisure, Price )------------- db1("UNB Recreation Inc", "UNB LB Gym", "1-506-453-4579", "Yoga", 30). db1("UNB Recreation Inc", "UNB LB Gym", "1-506-453-4578", "Strength Training", 40). db1("UNB Recreation Inc", "UNB LB Gym", "1-506-453-4578","Dancing Class",50). db1("UNB Recreation Inc","UNB LB Gym", "1-506-453-4522","Swimming", 20). db1("UNB Recreation Inc","UNB LB Gym","1-506-453-4533","Karate Class", 60). db1("UNB Recreation Inc","UNB LB Gym","1-506-453-4545","Climbing Club", 40). db1("UNB Recreation Inc","UNB LB Gym", "1-506-453-4545","Badminton Club", 10). db1("UNB Recreation Inc","UNB LB Gym","1-506-453-4545","Squash", 20). % -------DATA OF COMPANY B: db2(Name, Telephone, Address, Links, TypeOfLeisure, Price) -------------- db2("Royal Oaks country Club", "1-866-769-6257","1746 Elmwood Drive Moncton, New Brunswick E1H 2H6","http://www.royaloaks.nb.ca/welcome_en.htm","Golf", 60). db2("Royal Oaks country Club","1-866-769-6252","1746 Elmwood Drive Moncton, New Brunswick E1H 2H6","http://www.royaloaks.nb.ca/welcome_en.htm","Swimming", 20). db2("Royal Oaks country Club", "1-866-769-6253","1746 Elmwood Drive Moncton, New Brunswick E1H 2H6","http://www.royaloaks.nb.ca/welcome_en.htm","Dinner", 30). db2("Royal Oaks country Club","1-866-769-6254","1746 Elmwood Drive Moncton, New Brunswick E1H 2H6","http://www.royaloaks.nb.ca/welcome_en.htm","Biking", 20). db2("Royal Oaks country Club","1-866-769-6255","1746 Elmwood Drive Moncton, New Brunswick E1H 2H6","http://www.royaloaks.nb.ca/welcome_en.htm", "Hotel", 100). db2("Royal Oaks country Club","1-866-769-6256","1746 Elmwood Drive Moncton, New Brunswick E1H 2H6","http://www.royaloaks.nb.ca/welcome_en.htm","Tennis", 20). db2("Royal Oaks country Club","1-866-769-6233","1746 Elmwood Drive Moncton, New Brunswick E1H 2H6","http://www.royaloaks.nb.ca/welcome_en.htm","Hunting", 50). db2("Royal Oaks country Club","1-866-769-6223","1746 Elmwood Drive Moncton, New Brunswick E1H 2H6","http://www.royaloaks.nb.ca/welcome_en.htm","Kayaking", 30). db2("Royal Oaks country Club", "1-866-769-6250", "1746 Elmwood Drive Moncton, New Brunswick E1H 2H6", "http://www.royaloaks.nb.ca/welcome_en.htm", "Yoga", 100). db2("Royal Oaks country Club", "1-866-769-6259", "1746 Elmwood Drive Moncton, New Brunswick E1H 2H6", "http://www.royaloaks.nb.ca/welcome_en.htm", "Strength Training", 50). db2("Royal Oaks country Club", "1-866-769-6258", "1746 Elmwood Drive Moncton, New Brunswick E1H 2H6", "http://www.royaloaks.nb.ca/welcome_en.htm","Dancing Class",60). db2("Royal Oaks country Club", "1-866-769-6200","1746 Elmwood Drive Moncton, New Brunswick E1H 2H6", "http://www.royaloaks.nb.ca/welcome_en.htm","Swimming", 30). db2("Royal Oaks country Club", "1-866-769-6201","1746 Elmwood Drive Moncton, New Brunswick E1H 2H6","http://www.royaloaks.nb.ca/welcome_en.htm","Karate Class", 70). db2("Royal Oaks country Club", "1-866-769-6202","1746 Elmwood Drive Moncton, New Brunswick E1H 2H6","http://www.royaloaks.nb.ca/welcome_en.htm","Climbing Club", 50). % ------- DATA OF COMPANY C: db3(CompanyName, Where, Phone #, Website, Event Support, Cost) db3("Kingswood Park", "31 Kingswood Park Fredericton-New Brunswick E3C 2L4","1-506-444-9503","http://www.kingswoodpark.com/","Bowling", 20). db3("Kingswood Park", "31 Kingswood Park Fredericton-New Brunswick E3C 2L4","1-506-444-9503","http://www.kingswoodpark.com/","Fitness", 10). db3("Kingswood Park", "31 Kingswood Park Fredericton-New Brunswick E3C 2L4","1-506-444-9503","http://www.kingswoodpark.com/","Cinema", 10). db3("Kingswood Park", "31 Kingswood Park Fredericton-New Brunswick E3C 2L4","1-506-444-9503","http://www.kingswoodpark.com/","Laser game", 30). db3("Kingswood Park", "31 Kingswood Park Fredericton-New Brunswick E3C L4","1-506-444-9503", "http://www.kingswoodpark.com/","Golf", 60). db3("Kingswood Park", "31 Kingswood Park Fredericton-New Brunswick E3C 2L4","1-506-444-9503","http://www.kingswoodpark.com/","Tennis", 20). db3("Kingswood Park", "31 Kingswood Park Fredericton-New Brunswick E3C 2L4","1-506-444-9503","http://www.kingswoodpark.com/","Dinner", 30). db3("Kingswood Park", "31 Kingswood Park Fredericton-New Brunswick E3C 2L4","1-506-444-9503","http://www.kingswoodpark.com/", "Kid Zone", 10). db3("Kingswood Park", "31 Kingswood Park Fredericton-New Brunswick E3C 2L4", "1-506-444-9503","http://www.kingswoodpark.com/", "Yoga", 70). db3("Kingswood Park", "31 Kingswood Park Fredericton-New Brunswick E3C 2L4", "1-506-444-9503","http://www.kingswoodpark.com/", "Strength Training", 80). db3("Kingswood Park", "31 Kingswood Park Fredericton-New Brunswick E3C 2L4", "1-506-444-9503", "http://www.kingswoodpark.com/","Dancing Class",90). db3("Kingswood Park", "31 Kingswood Park Fredericton-New Brunswick E3C 2L4","1-506-444-9503", "http://www.kingswoodpark.com/","Swimming", 40). db3("Kingswood Park", "31 Kingswood Park Fredericton-New Brunswick E3C 2L4","1-506-444-9503","http://www.kingswoodpark.com/","Karate Class", 80). db3("Kingswood Park", "31 Kingswood Park Fredericton-New Brunswick E3C 2L4","1-506-444-9503","http://www.kingswoodpark.com/","Climbing Club", 30). db3("Kingswood Park", "31 Kingswood Park Fredericton-New Brunswick E3C 2L4","1-506-444-9503", "http://www.kingswoodpark.com/","Badminton Club", 50). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % ---------CUSTOMER DATA FOR COMPANY A Customer(ID, Name, Money, Address, Company)--------------------------- customer ("003", "Allen Iverson", 110, "8 Wilmot Street Fredericton", "UNB Recreation Inc"). customer ("032", "Jason Kidd", 80, "475 Beaverbrook Street Fredericton", "UNB Recreation Inc"). customer ("021", "Tim Duncan", 120, "321 Main Street Fredericton", "UNB Recreation Inc"). customer ("008", "Tony Parker", 150, "111 Goodine Street Fredericton", "UNB Recreation Inc"). customer ("006", "Tommy Jiang", 800, "15 Woodbridge Street", "UNB Recreation Inc"). customer ("007", "Yong Liang", 500, "602 Graham Ave.", "UNB Recreation Inc"). % ---------CUSTOMER DATA FOR COMPANY B Customer(ID, Name, Money, Address, Company)----------------------------- customer ("003", "Allen Iverson", 250, "8 Wilmot Street Fredericton", "Royal Oaks country Club"). customer ("032", "Jason Kidd", 180, "475 Beaverbrook Street Fredericton", "Royal Oaks country Club"). customer ("020", "Nicolas Cage", 80, "155 Regent Street", "Royal Oaks country Club"). customer ("021", "Tim Duncan", 500, "321 Main Street Fredericton", "Royal Oaks country Club"). customer ("008", "Tony Parker", 600, "111 Goodine Street Fredericton", "Royal Oaks country Club"). % ---------CUSTOMER DATA FOR COMPANY C Customer(ID, Name, Money, Address, Company)----------------------------- customer ("003", "Allen Iverson", 150, "8 Wilmot Street Fredericton", "Kingswood Park"). customer ("056", "Han Liang", 360, "602 Graham Ave.", "Kingswood Park"). customer ("032", "Jason Kidd", 130, "475 Beaverbrook Street Fredericton", "Kingswood Park"). customer ("021", "Tim Duncan", 240, "321 Main Street Fredericton", "Kingswood Park"). customer ("008", "Tony Parker", 300, "111 Goodine Street Fredericton", "Kingswood Park"). customer ("088", "Johny Depp", 800, "8 Woodbridge Street Fredericton", "Kingswood Park"). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % ---------DAYS OF DISCOUNTs OF COMPANY A---------------------------- holiday1("2006-01-01"). holiday1("2006-02-14"). holiday1("2006-03-15"). holiday1("2006-07-01"). holiday1("2006-11-01"). holiday1("2006-10-01"). holiday1("2006-05-01"). holiday1("2006-01-14"). holiday1("2006-02-12"). holiday1("2006-08-01"). holiday1("2006-09-09"). holiday1("2006-12-25"). %---------DAYS OF DISCOUNTs OF COMPANY B---------------------------------- holiday2("2006-01-01"). holiday2("2006-02-14"). holiday2("2006-09-09"). holiday2("2006-07-01"). holiday2("2006-10-01"). holiday2("2006-05-01"). holiday2("2006-04-05"). holiday2("2006-08-01"). holiday2("2006-12-25"). %---------DAYS OF DISCOUNTs OF COMPANY C------------------------------------ holiday3("2006-01-01"). holiday3("2006-11-01"). holiday3("2006-07-04"). holiday3("2006-05-01"). holiday3("2006-06-01"). holiday3("2006-03-27"). holiday3("2006-12-25"). %%%%%%%%%%%%%%%%%%%%%%%%%% - RULES - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %111111111111111111111111111111111111111111111111111111111111 %(RULE 1). MEDIATOR RULES USED TO TRANSFORM AN INPUT QUERY INTO SUB-QUERIES FOR COMPANIES %INPUT: A CUSTOMER’S QUERY %OUTPUT: DIFFERENT SUB-QUERIES FOR CORRESPONDING COMPANIES %PRECISE SEARCH ask4Services(TypeofLeisure, UserID,NumberofParticipant, Date,Price):- X.=ask4AServices("UNB Recreation Inc",TypeofLeisure,UserID,NumberofParticipant, Date,Price), Y.=ask4BServices("Royal Oaks country Club",TypeofLeisure,UserID, NumberofParticipant,Date,Price), Z.=ask4CServices("Kingswood Park",TypeofLeisure, UserID,NumberofParticipant, Date,Price) &cat([X],cat([Y],[Z])). %----------ADVANCED SEARCH: CHANGE TYPE OF THE INPUT LEISURE EVENT USING RULE 8.1 ------------ ask4Services1(TypeofLeisure, UserID,NumberofParticipant, Date,Price):- X.=ask4AServices1("UNB Recreation Inc",TypeofLeisure, UserID,NumberofParticipant, Date,Price), Y.=ask4BServices1("Royal Oaks country Club",TypeofLeisure,UserID, NumberofParticipant,Date,Price), Z.=ask4CServices1("Kingswood Park",TypeofLeisure, UserID,NumberofParticipant, Date,Price) &cat(X,cat(Y,Z)). %-----------ADVANCED SEARCH: CHANGE THE INPUT PRICE TO ALL PRICES USING RULE 8.2 ----------- ask4Services2(TypeofLeisure, UserID,NumberofParticipant, Date,Price):- X.=ask4AServices2("UNB Recreation Inc",TypeofLeisure, UserID,NumberofParticipant, Date,Price), Y.=ask4BServices2("Royal Oaks country Club",TypeofLeisure,UserID, NumberofParticipant,Date,Price), Z.=ask4CServices2("Kingswood Park",TypeofLeisure, UserID,NumberofParticipant, Date,Price) &cat([X],cat([Y],[Z])). %7777777777777777777777777777777777777777777777777777777777 % (rule7) PRECISE SEARCH %--- COMPANY A----- ask4AServices(CompanyName,TypeofLeisure,UserID,NumberOfParticipants, Date,Price):- db1(CompanyName,Where,ContactInfo,TypeofLeisure,_), P.=getPrice(UserID,CompanyName, TypeofLeisure, NumberOfParticipants,Date),>=(Price,P) & tup(CompanyName,Where,ContactInfo,TypeofLeisure,P). ask4AServices(CompanyName,TypeofLeisure,UserID,NumberOfParticipants, Date,Price):- db1(CompanyName,_,_,TypeofLeisure1,_) & []. %--- COMPANY B----- ask4BServices(CompanyName,TypeofLeisure,UserID, NumberofParticipants, Date,Price):- db2(CompanyName, ContactInfo, Where,Website,TypeofLeisure,_), P.=getPrice(UserID,CompanyName, TypeofLeisure, NumberOfParticipants,Date),>=(Price,P) & tup(CompanyName, Where,ContactInfo,TypeofLeisure,P). ask4BServices(CompanyName,TypeofLeisure,UserID, NumberofParticipants, Date,Price):- db2(CompanyName, _, _,_,TypeofLeisure1,_) & []. %--- COMPANY C----- ask4CServices(CompanyName, TypeofLeisure,UserID, NumberofParticipants, Date,Price):- db3(CompanyName, Where,ContactInfo,Website,TypeofLeisure, _), P.= getPrice(UserID,CompanyName, TypeofLeisure, NumberOfParticipants,Date),>=(Price,P) & tup(CompanyName, Where,ContactInfo,TypeofLeisure, P). ask4CServices(CompanyName,TypeofLeisure,UserID, NumberofParticipants, Date,Price):- db3(CompanyName,_,_,_,TypeofLeisure1, _) & []. %888888888888888888888888888888888888888888888888888888888 % (rule 8) ADVANCED SEARCH; %8.1-8.1-8.1-8.1-8.1-8.1-8.1-8.1-8.1 CHANGE TYPE OF THE INPUT LEISURE EVENT %--- COMPANY A----- ask4AServices1(CompanyName,TypeofLeisure,UserID,NumberOfParticipants, Date,Price):& tupof(db1(CompanyName,Where,ContactInfo,EveryTypeofLeisure,Price1), P.=getPrice(UserID,CompanyName, EveryTypeofLeisure,NumberOfParticipants,Date),>(Price,P), [CompanyName,Where,ContactInfo,EveryTypeofLeisure,P]). ask4AServices1(CompanyName,TypeofLeisure,UserID,NumberOfParticipants, Date,Price):- db1(CompanyName1,_,_,_,_) &[]. %--- COMPANY B----- ask4BServices1(CompanyName, TypeofLeisure,UserID, NumberofParticipants, Date,Price):& tupof(db2(CompanyName, ContactInfo, Where,Website,EveryTypeofLeisure,_), P.=getPrice(UserID,CompanyName, EveryTypeofLeisure,NumberOfParticipants,Date),>(Price,P), [CompanyName, Where, ContactInfo, EveryTypeofLeisure,P]). ask4BServices1(CompanyName, TypeofLeisure,UserID, NumberofParticipants, Date,Price):- db2(CompanyName1, _, _,_,_,_) & []. %--- COMPANY C----- ask4CServices1(CompanyName, TypeofLeisure,UserID, NumberofParticipants, Date,Price):& tupof(db3(CompanyName, Where,ContactInfo,Website,EveryTypeofLeisure, _), P.= getPrice(UserID,CompanyName, EveryTypeofLeisure, NumberOfParticipants,Date),>(Price,P), [CompanyName, Where,ContactInfo, EveryTypeofLeisure, P]). ask4CServices1(CompanyName, TypeofLeisure,UserID, NumberofParticipants, Date,Price):- db3(CompanyName1,_,_,_,_, _) & []. %8.2-8.2-8.2-8.2-8.2-8.2-8.2-8.2-8.2-8.2-8.2-8.2 CHANGE THE INPUT PRICE TO ALL PRICES %--- COMPANY A----- ask4AServices2(CompanyName,TypeofLeisure,UserID,NumberOfParticipants, Date,Price):- db1(CompanyName,Where,ContactInfo,TypeofLeisure,_), P.=getPrice(UserID,CompanyName, TypeofLeisure, NumberOfParticipants,Date) & tup(CompanyName,Where,ContactInfo,TypeofLeisure,P). ask4AServices2(CompanyName,TypeofLeisure,UserID,NumberOfParticipants, Date,Price):- db1(CompanyName,_,_,TypeofLeisure1,_) & []. %--- COMPANY B----- ask4BServices2(CompanyName, TypeofLeisure,UserID, NumberofParticipants, Date,Price):- db2(CompanyName, ContactInfo, Where,Website,TypeofLeisure,_), P.= getPrice(UserID,CompanyName, TypeofLeisure, NumberofParticipants,Date) & tup(CompanyName, Where, ContactInfo, TypeofLeisure,P). ask4BServices2(CompanyName, TypeofLeisure,UserID, NumberofParticipants, Date,Price):- db2(CompanyName, _, _,_,TypeofLeisure1,_) & []. %--- COMPANY C----- ask4CServices2(CompanyName, TypeofLeisure,UserID, NumberofParticipants, Date,Price):- db3(CompanyName, Where,ContactInfo,Website,TypeofLeisure, _), P.= getPrice(UserID,CompanyName, TypeofLeisure, NumberOfParticipants,Date) & tup(CompanyName, ContactInfo, Where,TypeofLeisure, P). ask4CServices2(CompanyName, TypeofLeisure,UserID, NumberofParticipants, Date,Price):- db3(CompanyName,_,_,_,TypeofLeisure1, _) & []. %22222222222222222222222222222222222222222222222222222222 %(rule2) Get the real price of a leisure service in a company after being discounted % if the input game is not exist, it will return UNKNOWN getPrice(UserID,CompanyName, LeisureService, NumberOfParticipants,Date):- string=(CompanyName,"UNB Recreation Inc")! X.=getHolidayDiscount1(Date), Y.=getGroupDiscount(CompanyName, LeisureService, NumberOfParticipants), ZZ.=membershipType(UserID,"UNB Recreation Inc"), Z.=getMembershipDiscount1(ZZ), db1("UNB Recreation Inc",_,_,LeisureService,Costfor1), BeginCost.=*(Costfor1,NumberOfParticipants), TotalDiscountRate.=+(+(X,Y),Z) & *(BeginCost,-(1,TotalDiscountRate)). getPrice(UserID,CompanyName, LeisureService, NumberOfParticipants,Date):- string=(CompanyName,"Royal Oaks country Club")! X.=getHolidayDiscount2(Date), Y.=getGroupDiscount(CompanyName, LeisureService, NumberOfParticipants), ZZ.=membershipType(UserID,"Royal Oaks country Club"), Z.=getMembershipDiscount2(ZZ), db2("Royal Oaks country Club",_,_,_,LeisureService,Costfor1), BeginCost.=*(Costfor1,NumberOfParticipants), TotalDiscountRate.=+(+(X,Y),Z) & *(BeginCost,-(1,TotalDiscountRate)). getPrice(UserID,CompanyName, LeisureService, NumberOfParticipants,Date):- string=(CompanyName,"Kingswood Park")! X.=getHolidayDiscount3(Date), Y.=getGroupDiscount(CompanyName, LeisureService, NumberOfParticipants), ZZ.=membershipType(UserID,"Kingswood Park"), Z.=getMembershipDiscount3(ZZ), db3("Kingswood Park",_,_,_,LeisureService,Costfor1), BeginCost.=*(Costfor1,NumberOfParticipants), TotalDiscountRate.=+(+(X,Y),Z) & *(BeginCost,-(1,TotalDiscountRate)). %333333333333333333333333333333333333333333333333333333 %(Rule 3) GET A HOLIDAY DISCOUNT RATE getHolidayDiscount1(Date):- holiday1(Date)!&0.05. getHolidayDiscount1(Date):& 0. getHolidayDiscount2(Date):- holiday2(Date)!&0.1. getHolidayDiscount2(Date):& 0. getHolidayDiscount3(Date):- holiday3(Date)!&0.08. getHolidayDiscount3(Date):& 0. %4444444444444444444444444444444444444444444444444444444 %(Rule 4) GET DISCOUNT RATES FOR A GROUP OF PARTICIPANTS getGroupDiscount(CompanyName, LeisureService, NumberOfParticipants):- string=(CompanyName, "UNB Recreation Inc"), string=(LeisureService, "Yoga"), >(NumberOfParticipants,8)!&0.1. getGroupDiscount(CompanyName, LeisureService, NumberOfParticipants):- string=(CompanyName, "UNB Recreation Inc"), string=(LeisureService, "Tennis"), >(NumberOfParticipants,10)!&0.2. getGroupDiscount(CompanyName, LeisureService, NumberOfParticipants):- string=(CompanyName, "Royal Oaks country Club"), string=(LeisureService, "Swimming"), >(NumberOfParticipants,15)!&0.2. getGroupDiscount(CompanyName, LeisureService, NumberOfParticipants):- string=(CompanyName, "Kingswood Park"), string=(LeisureService, "Fitness"), >(NumberOfParticipants,15)!&0.15. getGroupDiscount(CompanyName, LeisureService, NumberOfParticipants):&0.0. %55555555555555555555555555555555555555555555555555555 %(Rule 5) GET A MEMBERSHIP DISCOUNT RATE getMembershipDiscount1(MembershipType):- string=(MembershipType, "VIP")! &0.1. getMembershipDiscount1(MembershipType):&0. getMembershipDiscount2(MembershipType):- string=(MembershipType, "VIP")! &0.05. getMembershipDiscount2(MembershipType):&0. getMembershipDiscount3(MembershipType):- string=(MembershipType, "VIP")! &0.15. getMembershipDiscount3(MembershipType):&0. %66666666666666666666666666666666666666666666666666666666 %(Rule 6) GET A MEMBERSHIP TYPE FOR A REGISTERING USER IN A COMPANY membershipType(UserID,"UNB Recreation Inc"):-customer(UserID,_,X,_,"UNB Recreation Inc"),>(X,200)! &"VIP". membershipType(UserID,"Royal Oaks country Club"):-customer(UserID,_,X,_,"Royal Oaks country Club"), >(X,300)! &"VIP". membershipType(UserID,"Kingswood Park"):-customer(UserID,_,X,_,"Kingswood Park"),>(X,400)!&"VIP". membershipType(UserID,_):&"Regular". %999999999999999999999999999999999999999999999999999999 %(Rule 9) SORTING A LIST ACCORDING TO THE ASCENDING OF A PRICE OF EACH SERVICE insert_sort(List,Sorted):-i_sort(List,[],Sorted). i_sort([],Acc,Acc). i_sort([H|T],Acc,Sorted):-insert(H,Acc,NAcc),i_sort(T,NAcc,Sorted). insert(X,[Y|T],[Y|NT]):- A.=compare(X,Y),A.=1,insert(X,T,NT). insert(X,[Y|T],[X,Y|T]):-A.=compare(X,Y),A.=0. insert(X,[],[X]). compare(A,[]):&0. compare([],A):&1. compare([CompanyName1,Where1,ContactInfo1,TypeofLeisure1,P1],[CompanyName2,Where2,ContactInfo2,TypeofLeisur2,P2]):->(P1,P2)!&1. compare([CompanyName1,Where1,ContactInfo1,TypeofLeisure1,P1],[CompanyName2,Where2,ContactInfo2,TypeofLeisure2,P2]):&0. % ================ AUXILIARY RULES: cat and cns =================== cns(First,Rest) :& [First|Rest]. cns([],Rest):& Rest. cat([],L) :& L. cat([F|R],L) :& cns(F,cat(R,L)). %%%%%%%%%%%%%%%%%%%%%%%%%%%% --USER INPUT-- %%%%%%%%%%%%%%%%%%%%%%%%%% userPreciseQuery(TypeofLeisure, UserID,NumberofParticipant, Date,Price,Result):- X.=ask4Services(TypeofLeisure, UserID,NumberofParticipant, Date,Price), insert_sort(X,Result). userAdvanceQuery1(TypeofLeisure, UserID,NumberofParticipant, Date,Price,Result):- X.=ask4Services1(TypeofLeisure, UserID,NumberofParticipant, Date,Price), insert_sort(X,Result). userAdvanceQuery2(TypeofLeisure, UserID,NumberofParticipant, Date,Price,Result):- X.=ask4Services2(TypeofLeisure, UserID,NumberofParticipant, Date,Price), insert_sort(X,Result). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%% USER QUERIES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% yl1():& ask4AServices("UNB Recreation Inc", "Yoga","003",10, "2006-01-01",20). yl2():& ask4AServices2("UNB Recreation Inc", "Yoga","003",10, "2006-01-01",20). yl3():& ask4Services2("Yoga","003",10, "2006-01-01",20). yl4(Result):&insert_sort([["UNB Recreation Inc","UNB LB Gym","1-506-453-4579","Yoga",255.0], ["Royal Oaks country Club", "1746 Elmwood Drive Moncton, New Brunswick E1H 2H6", "1-866-769-6250", "Yoga", 900.0], ["Kingswood Park", "1-506-444-9503", "31 Kingswood Park Fredericton-New Brunswick E3C 2L4", "Yoga", 644.0]],Result). yl5(Result):-userPreciseQuery("Swimming","003",10,"2006-01-01",500,Result). yl6(Result):-userAdvanceQuery1("Swimming","003",10,"2006-01-01",500,Result). yl7(Result):-userAdvanceQuery2("Swimming","003",10,"2006-01-01",500,Result). yl8(Result):-userPreciseQuery("Fitness","003",10,"2006-01-01",500,Result). thuy1():& ask4Services("Swimming", "003",10, "2006-01-01", 500). thuy2():& ask4AServices("UNB Recreation Inc", "Swimming","003",10, "2006-01-01",500). thuy3():& ask4BServices("Royal Oaks country Club","Swimming","003",10, "2006-01-01",500). thuy4():& ask4CServices("Kingswood Park","Swimming","003",10,"2006-01-01",500). thuy5():& ask4Services("Swimming", "003",10, "2006-01-01",200). thuy6():& ask4Services1("Swimming", "003",10, "2006-01-01",200). xh1():&getMembershipDiscount1("VIP"). xh2():&getMembershipDiscount1("Regular"). xh3():&getMembershipDiscount2("VIP"). xh4():&getMembershipDiscount3("VIP"). xh5():&membershipType("003","UNB Recreation Inc"). xh6():&membershipType("007","UNB Recreation Inc"). xh7():&membershipType("032","Royal Oaks country Club"). xh8():&membershipType("021","Royal Oaks country Club"). han1():&getGroupDiscount("UNB Recreation Inc", "Yoga", 30). han2():&getHolidayDiscount1("2006-01-01"). han3():&getPrice("006","UNB Recreation Inc", "Swimming", 20,"2006-01-01").