SHARE
TWEET

Untitled

a guest Dec 10th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. domains
  2.     professor = symbol.    % ??? ??????????
  3.     lesson = symbol.    % ???????? ????????
  4.     day = symbol.     % ???? ??????
  5.     time = symbol.   % ?????
  6. database
  7.     working_time(professor, day, time, time).
  8.     professors(professor, lesson).
  9. predicates
  10.     nondeterm choice(integer).
  11.     nondeterm repeat.
  12.     nondeterm menu.
  13.     nondeterm whoCanChange(lesson, professor, professor, day, time).
  14.     nondeterm ints(integer).
  15. clauses
  16.     ints(0).
  17.     ints(X) :- ints(Y), X is Y + 1.
  18.     whoCanChange(LessonName, Professor, FreeProfessor, Day, Time) :-
  19.         professors(FreeProfessor, LessonName), % Ïîëó÷àåì âñåõ ïðåïîäàâàòåëåé, êîòîðûå ìîãóò âåñòè ïðåäìåò {LessonName}
  20.         FreeProfessor <> Professor, % Óáèðàåì ïðîôåññîðà, êîòîðîãî çàìåíÿåì
  21.         working_time(FreeProfessor, BusyDay, BusyTimeFrom, BusyTimeTo), % Ïîëó÷àåì âðåìÿ ðàáîòû âòîðîãî ïðîôåññîðà
  22.         BusyDay = Day, % Ïîëó÷àåì âðåìÿ ðàáîòû âòîðîãî ïðîôåññîðà â íóæíûé äåíü
  23.         BusyTimeFrom >= Time. % Âðåìÿ, ñ êîòîðîãî çàíÿò ïðîôåññîð äîëæíî íà÷èíàòüñÿ ïîçæå íóæíîãî âðåìåíè
  24.  
  25.     whoCanChange(LessonName, Professor, FreeProfessor, Day, Time) :-
  26.         professors(FreeProfessor, LessonName), % Ïîëó÷àåì âñåõ ïðåïîäàâàòåëåé, êîòîðûå ìîãóò âåñòè ïðåäìåò {LessonName}
  27.         FreeProfessor <> Professor, % Óáèðàåì ïðîôåññîðà, êîòîðîãî çàìåíÿåì
  28.         working_time(FreeProfessor, BusyDay, BusyTimeFrom, BusyTimeTo), % Ïîëó÷àåì âðåìÿ ðàáîòû âòîðîãî ïðîôåññîðà
  29.         BusyDay = Day, % Ïîëó÷àåì âðåìÿ ðàáîòû âòîðîãî ïðîôåññîðà â íóæíûé äåíü
  30.         BusyTimeTo <= Time. % Âðåìÿ, äî êîòîðîãî çàíÿò ïðîôåññîð äîëæíî êîí÷àòüñÿ ðàíüøå íóæíîãî âðåìåíè
  31.     choice('1') :- write("Professor's name: "), readln(Professor),    
  32.                     write("Write lesson: "), readln(Lesson),
  33.                             assert(professors(Professor, Lesson)), fail.
  34.     choice('2') :- write("Write new working time: Professor, Day, Time from, time to: "),
  35.                  readln(Professor), readln(Day), readln(TimeFrom), readln(TimeTo),
  36.                              assert(working_time(Professor, Day, TimeFrom, TimeTo)), fail.
  37.     choice('3') :-working_time(Professor, Day, TimeFrom, TimeTo), write(Professor, "work at ", Day, " from ", TimeFrom, " to ", TimeTo,"\n"),fail.
  38.    
  39.    
  40.     choice('4') :- professors(Professor, Lesson), write(Professor, " teach ", Lesson, "\n"), ints(Sum), fail,  write("\n",Sum,"\n").
  41.     /*choice('4') :-findall(Professor, professors(Professor, _), L),
  42.  
  43.  
  44.             count(L, 0),
  45.             fail.*/
  46.    
  47.    
  48.     choice('5') :- write("Professor's name: "), readln(Professor), write("Write lesson: "), readln(Lesson),
  49.                 write("Day of lesson: "), readln(Day), write("Time: "), readln(Time),
  50.                 whoCanChange(Lesson, Professor, FreeProfessor, Day, Time), write(FreeProfessor), fail.
  51.     choice('6') :- write("Load from "), readln(Name), consult(Name), fail.
  52.     choice('7') :- write("Save to :\n"), readln(Name), save(Name), !.
  53.     menu :- repeat, write("Select action: \n"),
  54.         write("1: Add Professor\n"),
  55.         write("2: Add working_time\n"),
  56.         write("3: TimeTable\n"),
  57.         write("4: All Professors\n"),
  58.         write("5: Who can change\n"),
  59.         write("6: Load from file\n"),
  60.         write("7: Save to file and exit program\n"),
  61. readchar(Choice), choice(Choice).
  62.     repeat.
  63.         repeat :- repeat.
  64.  
  65. goal
  66.     menu.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top