% File "object.tu". % % Written by Phil Edmonds, Feb 97. % % This is the basic object class. Objects have a location, name, and colour. % The Drawself and EraseSelf are deferred since a basic object has no image. % %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ unit class Object import Location in "location.tu" export Init, Prnt, DrawImage, EraseImage %========== INSTANCE VARIABLES ============================== %============================================================ var loc : ^Location var name : string var col : int %========== PUBLIC FUNCTIONS ================================ %============================================================ % initialize the three instance variables %------------------------------------------------------------ proc Init (x, y : real, n: string, c : int) col := c name := n % must instantiate a new location, since locations are objects new loc loc -> SetX (x) loc -> SetY (y) end Init % print the name %------------------------------------------------------------ proc Prnt(stream : int) put :stream, name .. end Prnt deferred proc DrawImage deferred proc EraseImage end Object