



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Fall 2006
BouncingBall Circle draw() Ball draw () Rectangle draw()
Factory Method To define an interface for creating an object, but let subclasses to decide which class to instantiate. Product ConcreteProduct AbstractClass factoryMethod operation() () ConcreteClass factoryMethod() (^) return new ConcreteProduct(); p = factoryMethod(); Outline ļ¼Factory method
Adapter
Client operation^ Target () operation()^ Adaptee adaptee.operation(); Adapter operation() Adapter (Cont.) Client operation^ Target () operation()^ Adaptee Adapter Outline ļ¼Factory method ļ¼Adapter
AWT Components Bouncing Multiple Balls Using Composite Pattern (Cont.)
Iterator Pattern Collection iterator () Iterator hasNext next ()() ConcreteCollection iterator() ConcreteIterator <
Template Methods
AbstractClass templateMethod() hookMethod1 () hookMethod2 () ConcreteClass hookMethod1() hookMethod2() ⦠hookMethod1() ⦠hookMethod2() ⦠Template Methods (Cont.)
More Example
Plotter func paint()() plotFunction() plotCoordinates() PlotSine func() ⦠func() ⦠Applet PlotCosine func()