29.11.2014 Views

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

compactness a tree structure c<strong>an</strong> be used to show multiple subclasses inheriting from a single<br />

superclass.<br />

Animal<br />

Mammals<br />

Hum<strong>an</strong>s<br />

Lecturers<br />

Figure 17.13: Inherit<strong>an</strong>ce : specialization - generalization<br />

Multiple inherit<strong>an</strong>ce c<strong>an</strong> also be modeled as l<strong>an</strong>guages such as CLOS (the Common Lisp <strong>Object</strong><br />

System) <strong><strong>an</strong>d</strong> C++ support it. This is done by drawing multiple inherit<strong>an</strong>ce lines from a single subclass to<br />

two or more super classes as in Figure 17.14. In this figure the class Motor powered water vehicle<br />

inherits from both Motor powered <strong><strong>an</strong>d</strong> Water vehicle.<br />

Vehicle<br />

Motor<br />

Powered<br />

Water Vehicle<br />

Motor Powered<br />

Water Vehicle<br />

Jet ski<br />

Motor Boat<br />

Figure 17.14: Multiple Inherit<strong>an</strong>ce<br />

Derived values c<strong>an</strong> be repr esented by a slash (‘/’) in front of the name of the derived attribute. Such<br />

<strong>an</strong> attribute requires <strong>an</strong> additional textual constraint defining how it is generated (as in Figure 17.15).<br />

This is indicated by a textual <strong>an</strong>notation below the class between curly ({}) brackets.<br />

Person<br />

birthdate<br />

/age<br />

{age = currentDate - birthdate}<br />

Figure 17.15: Derived values<br />

144

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

Saved successfully!

Ooh no, something went wrong!