SUNY Geneseo Department of Computer Science
Algorithm
Design with Objects
{Date}
CSci 141, Spring 2005
Prof. Doug Baldwin
Return
to List of Lectures
Previous Lecture
Misc
Hand out Lab 2
Questions?
Reading Summary
Chapter 2
Abstraction
Value-producing algorithms vs side-effect
producing algorithms
Subclasses, e.g., drawing robots, show
different things you can do
Preconditions and postconditions, contract
between clients and implementors re
interface to algorithm
Implementor deals with "dirty bits" inside
algorithm, client should see clean, simple
interface
Mini-Chess
Examples of object-oriented concepts
What concepts from the reading were there in
this game?
- Preconditions: initial set-up
- Also for moving (can't move through occupied
square, etc)
- Postconditions: check mate
- And for moving (taken pieces, positions
change)
- Classes & subclasses
- "Piece" is a class
- Have color
- All can move
- But not if it goes off board
- If move reaches another piece,
it's captured
- "Captured" vs "not captured"
- "Pawn," "knight," etc. are subclasses
- Inheritance: e.g., "color" property
- "Board" could also be a class
- "Move" is a message
- (Also "castle" in full chess)
- "Move" needs information about where to move to - parameter
Next
Theoretical Reasoning about Algorithms
Read Sections 3.1 - 3.3, 3.6
Next Lecture