30.12.2013 Views

Chapter 6: Inheritance and Abstract Classes Chapter Topics 6.1 ...

Chapter 6: Inheritance and Abstract Classes Chapter Topics 6.1 ...

Chapter 6: Inheritance and Abstract Classes Chapter Topics 6.1 ...

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.

CS151 Object-Oriented Design<br />

Dr. Kim<br />

4. Each subclass defines the primitive operations but not the algorithm.<br />

Structure<br />

Example: the drawSelection method defined in the abstract class SelectableShape<br />

Name in Design Pattern<br />

<strong>Abstract</strong>Class<br />

ConcreteClass<br />

templateMethod()<br />

primitiveOp1(), primitiveOp2()<br />

Actual Name (Selectable shapes)<br />

SelectableShape<br />

CarShape, HouseShape<br />

drawSelection<br />

translate, draw<br />

6.5 protected visibility<br />

In this section, we will create one more super class called CompoundShape to move the common<br />

features of house <strong>and</strong> car shapes to this super class.<br />

24

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

Saved successfully!

Ooh no, something went wrong!