;; ;; frames ;; (defclass AIRPORT (is-a USER) (role concrete) (slot code (create-accessor read-write)) (slot AD-name (create-accessor read-write)) (slot city (create-accessor read-write)) (slot country (create-accessor read-write)) ) (make-instance [LYS] of AIRPORT (code LYS) (AD-name Satolas) (city Lyon) (country France)) (make-instance [LHR] of AIRPORT (code LHR) (AD-name Heathrow) (city London) (country Britain)) (defclass FLIGHT (is-a USER) (role concrete) (slot code (type SYMBOL)(create-accessor read-write)) (slot from (type INSTANCE)(create-accessor read-write)) (slot to (type INSTANCE)(create-accessor read-write)) (message-handler from-city) (message-handler to-city) ) (defmessage-handler FLIGHT from-city() (send ?self:from get-city)) (defmessage-handler FLIGHT to-city() (send ?self:to get-city)) (make-instance [AF357] of FLIGHT (from [LHR]) (to [LYS])(code AF357) ) (send [AF357] from-city) (send [AF357] to-city) ;; ;; Schema pour une voyage ;; (defclass ACTOR (is-a USER) (role concrete) (slot actor (create-accessor read-write)) (message-handler who) ) (defmessage-handler ACTOR who () (return ?self:actor)) (make-instance [JIM] of ACTOR (actor Jim)) ;; Un voyage est une ³event² ;; (defclass EVENT (is-a USER) (slot t1 (create-accessor read-write)) (slot t2 (create-accessor read-write)) ) (defclass DATE (is-a EVENT) (role concrete) (slot day (create-accessor read-write)) (slot month (create-accessor read-write)) (slot year (create-accessor read-write)) (slot day-of-week (create-accessor read-write)) ) (make-instance [WED] of DATE (day-of-week Wednesday) (day 9)(month march)(year 94)) (defclass VOYAGE (is-a EVENT) (role concrete) (slot to (type INSTANCE) (create-accessor read-write)) (slot from (type INSTANCE) (create-accessor read-write)) (slot date (type INSTANCE) (create-accessor read-write)) (slot travel-mode (type LEXEME) (create-accessor read-write)) (slot voyager (type INSTANCE) (create-accessor read-write)) (message-handler who) (message-handler where) (message-handler when) (message-handler how) ) (make-instance [V] of VOYAGE (to London) (from Lyon) (date [WED]) (travel-mode fly) (voyager [JIM]) ) ;; ³who² est un message-handlre pour le now de voyager ;; on appelle le voyager d¹obtenir who. (defmessage-handler VOYAGE who () (send ?self:voyager who)) ;; ;; "where" depend de la sorte d'endroit. ;; ici on fait un simple get-to ;; (defmessage-handler VOYAGE where() (return ?self:to) ) ;; when est une date composee ;; on voit ici comment composer une ³string². (defmessage-handler VOYAGE when() (bind ?month (send ?self:date get-month)) (bind ?day (send ?self:date get-day)) (bind ?year (send ?self:date get-year)) (return (str-cat ?day " " ?month " " ?year)) ) (defmessage-handler VOYAGE how () (return ?self:travel-mode) ) ;; ;; On peut être plus precis avec les description des "places" ;; (defclass PLACE (is-a USER) (slot place-name (create-accessor read-write)) (slot city (create-accessor read-write)) (slot country (default France) (create-accessor read-write)) (message-handler where) ) ;; définir where comme , (defmessage-handler PLACE where () (str-cat ?self:city ", " ?self:country) ) (defclass AIRPORT (is-a PLACE) (role concrete) (slot code (create-accessor read-write)) ) (make-instance [LHR] of AIRPORT (code LHR) (city London) (place-name Heathrow) (country UK)) (make-instance [LYS] of AIRPORT (code LYS) (place-name Satolas) (city Lyon) (country France) ) (send [LYS] where) (send [LHR] where) (defclass PERSON (is-a ACTOR) (role concrete) (slot last-name (create-accessor read-write)) (slot first-name (create-accessor read-write)) (slot initials (create-accessor read-write)) (message-handler who) ) (make-instance [JIM] of PERSON (last-name CROWLEY) (first-name James) (initials L) ) (defmessage-handler PERSON who () (str-cat ?self:first-name " " ?self:initials ". " ?self:last-name) ) (defclass AF357 (is-a VOYAGE) (role concrete) (slot to (default [LYS]) (create-accessor read-write)) (slot from (default [LHR]) (create-accessor read-write)) (slot travel-mode (default Flying) (create-accessor read-write)) (slot t1 (default 1800) (create-accessor read-write)) (slot t2 (default 2130) (create-accessor read-write)) ) (defmessage-handler AF357 where () (send ?self:to where)) ) (defmessage-handler AF357 who () (send ?self:voyager who) ) (make-instance [AF357] of AF357 (date [WED] ) (voyager [JIM]) ) ;; ;; [AF357] a heriter who, when, where and how ;; (send [AF357] when) (send [AF357] where) (send [AF357] how) (send [AF357] who) (send [AF357] get-to)