This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/Logtalk/examples/lpa/timetables/teachers.lgt
pmoura 3455276aa2 Logtalk 2.26.2 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1487 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2005-12-24 18:07:41 +00:00

129 lines
2.0 KiB
Plaintext

:- object(teachers).
:- info([
version is 1.0,
date is 2005/5/8,
author is 'Example by LPA; adapted to Logtalk by Paulo Moura.',
comment is 'General attributes & methods for all teachers.']).
:- public(print/0).
:- info(print/0, [
comment is 'Print teachers timetable.']).
print :-
nl, write('TEACHER TIMETABLE ...'), nl, nl,
forall(extends_object(Teacher, teacher), Teacher::print),
nl.
:- end_object.
:- object(teacher).
:- info([
version is 1.0,
date is 2005/5/8,
author is 'Example by LPA; adapted to Logtalk by Paulo Moura.',
comment is 'General attributes & methods for all teachers.']).
:- public(teach_period/1).
:- info(teach_period/1, [
comment is 'A period for which the teacher can be assigned.']).
:- public(teach_subject/1).
:- info(teach_subject/1, [
comment is 'A subject which the teacher can teach.']).
:- public(print/0).
:- info(print/0, [
comment is 'Print complete timetable from the teacher viewpoint.']).
:- public(freetime/1).
:- info(freetime/1, [
comment is '.',
argnames is ['Freetime']]).
:- public(subject/1).
:- info(subject/1, [
comment is '.',
argnames is ['Subject']]).
teach_period(Period) :-
\+ ::freetime(Period).
teach_subject(Subject) :-
::subject(Subject).
print :-
self(Self),
write('TEACHER: '), write(Self), nl,
forall(extends_object(Period, period), Period::print_teacher(Self)),
nl.
:- end_object.
:- object(nicky,
extends(teacher)).
subject(french).
subject(biology).
freetime(1).
freetime(4).
:- end_object.
:- object(brian,
extends(teacher)).
subject(maths).
subject(music).
:- end_object.
:- object(dave,
extends(teacher)).
subject(maths).
:- end_object.
:- object(clive,
extends(teacher)).
subject(french).
subject(prolog).
freetime(2).
freetime(3).
freetime(5).
:- end_object.
:- object(diane,
extends(teacher)).
subject(accountancy).
freetime(2).
freetime(4).
:- end_object.
:- object(phil,
extends(teacher)).
subject(maths).
subject('prolog++').
freetime(3).
:- end_object.