18.10.2014 Views

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>SIMSCRIPT</strong> <strong>II.5</strong> <strong>Programming</strong> <strong>Language</strong><br />

TANKER<br />

TUG<br />

word 1 SPEED SPEED<br />

word 2 P.HARBOR.SET P.HARBOR.SET<br />

word 3 S.HARBOR.SET S.HARBOR.SET<br />

word 4 M.HARBOR.SET M.HARBOR.SET<br />

word 5 CARGO<br />

Figure 4-21. Entity Structures for TANKER and TUG<br />

Word numbers are described in detail in Chapter 6.<br />

Care should be taken not to reference CARGO with a pointer which could be identifying an instance<br />

of a TUG entity. Thus:<br />

for each SHIP in HARBOR.SET<br />

with CARGO(SHIP) greater than 100<br />

.<br />

.<br />

would be incorrect if there were, in fact, any TUG entities in the HARBOR.SET. Clearly TUG entities<br />

do not have any CARGO.<br />

In general, where common sets are used, it is good practice to declare a common attribute which<br />

can serve to discriminate between the different entity types sharing membership of a common set.<br />

Recall that in the context of permanent entities, attribute references are actually references to attribute<br />

arrays. Multiple definition of such an array is not permitted. Hence, permanent attributes<br />

cannot be declared as common.<br />

4.11 Compound Entities<br />

At times it is convenient for several entities jointly to have attributes and own sets. Such entities<br />

are called compound entities. Statements such as:<br />

permanent entities<br />

every MAN and WOMAN owns a FAMILY and has<br />

a BANK.ACCOUNT<br />

every CITY, COUNTY, STATE has a CENSUS<br />

every MODEL, COLOR, YEAR, MFG has a SALES.VOLUME<br />

define compound entities composed of 2, 3, and 4 permanent entities, respectively. The first defines<br />

four two-dimensional arrays: F.FAMILY, L.FAMILY, N.FAMILY, and BANK.ACCOUNT, each dimensioned<br />

as N.MAN BY N.WOMAN. The second defines a three-dimensional array CENSUS dimen-<br />

170

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!