17.2.1 Physical objects
The classes that follow describe fundamental attributes of tangible objects.
The |
|---|
module: airport
// PHYSICAL OBJECTS AND SIZE
// Used to keep track of object dimensions and object capacities
// All dimensions are in feet
define class <size> (<object>)
slot length :: <positive-integer>, init-keyword: length:;
slot width :: <positive-integer>, init-keyword: width:;
slot height :: <positive-integer>, init-keyword: height:;
end class <size>;
define abstract class <physical-object> (<object>)
slot current-position :: <position>, init-keyword: current-position:;
slot physical-size :: <size>, init-keyword: physical-size:;
end class <physical-object>;
define method say (physical-object :: <physical-object>) => ()
format-out("object at ");
say(physical-object.current-position);
end method say;
|
In the preceding portion of the airport-classes.dylan file, we define the class <size>, which allows us to specify the external dimensions and container volume of various objects. For example, we might want to specify that certain gate areas might be too small to hold the large aircraft. We also define the base class for all tangible objects, <physical-object>.
Next, we define the classes where aircraft are normally located.




