13 Frames, Inheritance, Demons
Write a simple shell for the processing of frames according to the lecture script. The frames will be represented in Prolog as
frame_id( slot, facet, value).
such that they can be accessed easily.
The shell should support the following operations:
get_value( Frame, Slot, Value) put_value( Frame, Slot, Value) create_instance( Frame, Instance_Frame).
The predicate create_instance( Frame, Instance_Frame) creates the frame Instance_Frame with the is_a relationship to Frame.
The following facets should be supported:
value, if_needed, if_added.
The corresponding demons are triggered automatically when the functions (Prolog predicates) get_value und put_value are called. The demon funkcions (Prolog predicates) are defined as:
demon( Frame, Slot, Value) :- .... .
Apply the shell from Example 13.1 to create a hierarchy of graphical objects:
Graphical object (slots: position (x,y)):
- Rectangle (own slots: site_x, site_y, area (if_needed))
- Square (own slots: site_x (if_added -> site_y), site_y (if_needed)).
- Ellipse (own slots: axis_x, axis_y, area (if_needed))
- Circle (own slots: radius, axis_x (if_needed), axis_y (if_needed), area (if_needed)).
It should be possible to create instances of these classes with as few inputs as possible.
You can add further slots and extend the hierarchy.