Beruflich Dokumente
Kultur Dokumente
2 Oct 2007
Peter Andreae
COMP 102 :2
Multi-Class programs
Class Diagrams
Designing MiniDraw
Implementing Interface classes.
Reading:
Reading
Computer Science
Victoria University of Wellington
Announcements:
Announcements
Lab 10 available
Copyright: Peter Andreae, Victoria University of Wellington 2007
Peter Andreae
Designing Programs
COMP 102 :3
Designing Programs
COMP 102 :4
methods:
classes:
Abstraction:
Hiding the details of a module, so that other parts
of the program only need to know a little bit about it:
eg:
name, parameters, return type
constructor and possible actions
Questions: what should you show? what should you hide?
Peter Andreae
Peter Andreae
Designing Classes
COMP 102 :5
CartoonStrip
COMP 102 :6
(Assig 5)
ScreenSaver
CartoonFigure
MovingShape
(Assig 8)
MineSweeper
Garden
Grid
Flowers
Cell
Peter Andreae
Designing Classes
(The interface that controlled the toons)
COMP 102 :7
(The user interface
and control loop)
(Assig 5)
CartoonFigure
MovingShape
(Assig 9)
MineSweeper
min = Integer.MAX_VALUE;
eg, in Grid.java:
Grid
Flowers
Garden
COMP 102 :8
Class Diagrams
Box for each class
ScreenSaver
CartoonStrip
Peter Andreae
(Individual Squares)
Cell
Peter Andreae
Class Diagrams
COMP 102 :9
[ L&L: 4.1 ]
Interface
Interface is ambiguous:
javadoc documentation
Class interface:
boundary between class and rest of program
A Java Interface:
Peter Andreae
(Assig 5)
ScreenSaver
Peter Andreae
MovingShape
different colours.
can add a new shape,
remove a shape
Constructor Summary
Method Summary
void draw ()
Draw the shape on the canvas in its current position
void erase ()
Erase the rectangle containing the shape
void move (int stepX, int stepY)
Move the shape by the given step size.
Peter Andreae
Peter Andreae