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.

3. Constructing <strong>an</strong> <strong>Object</strong> Oriented System<br />

3.1 <strong>Introduction</strong><br />

This chapter takes you th rough the design of a simple object oriented system. It does not concern itself<br />

with implementation issues nor with the details of <strong>an</strong>y particular l<strong>an</strong>guage. Instead, the aim of this<br />

chapter is to illustrate how the concepts described in the last two chapter s c<strong>an</strong> be used to construct a<br />

software system. In the remainder of the chapter we describe the application to be constructed. We then<br />

consider where to start looking for objects <strong><strong>an</strong>d</strong> from there, what the objects should do <strong><strong>an</strong>d</strong> how they<br />

should do it. We conclu de by discussing issues such as class inherit<strong>an</strong>ce <strong><strong>an</strong>d</strong> <strong>an</strong>swer questions such as<br />

“where is the structure of the program?”.<br />

3.2 The application: windscreen wipe simulation<br />

Wash wipe<br />

switch<br />

Wiper<br />

motor<br />

-<br />

Relay<br />

+<br />

Fuse<br />

Pump<br />

Water<br />

bottle<br />

Figure 3.1: The windscreen wash wipe system structure<br />

The aim of this system is to provide a system diagnosis tutor for the equipment illustrated in Figure 3.1.<br />

That is, rather th<strong>an</strong> use the wash wipe system from a real car, students on a car mech<strong>an</strong>ics diagnosis<br />

course will use this software simulation. The software system will provide a simulation whose behavior<br />

will mimic that of the actual system, thus the behavior of the pump will depend on information provided<br />

by the relay <strong><strong>an</strong>d</strong> the water bottle.<br />

The operation of the wash wipe system is controlled by the wash wipe switch which c<strong>an</strong> be in one of<br />

5 different positions. These are: off, intermittent, slow, fast <strong><strong>an</strong>d</strong> wash. Each of these settings places the<br />

system into a different state:<br />

OFF. The system is inactive.<br />

INTERMITTENT. The wiper motor wipes the wiper blades across the windscreen (or windshield<br />

if you are Americ<strong>an</strong>) every few second.<br />

SLOW. The wiper motor continuously wipes the wiper blades across the windscreen.<br />

FAST. The wiper motor continuously wipes the wiper blades quickly across the windscreen.<br />

WASH. The wash setting is a power wash in which the water pump sprays water onto the<br />

windscreen. This water is drawn from the water bottle.<br />

For the pump or the wiper motor to work corr ectly, the relay must function correctly. In turn the relay<br />

must be supplied with <strong>an</strong> electrical circuit. This electrical circuit is negatively fused <strong><strong>an</strong>d</strong> thus the fuse<br />

must be intact for the circuit to be made. Note cars (automobiles) are negatively switche d as this<br />

reduces the ch<strong>an</strong>ces of short circuits which lead to unintentional switching of circuits.<br />

34

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

Saved successfully!

Ooh no, something went wrong!