DesignPatterns

DesignPatterns - CSE 219 Patterns in Programming Design...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 219 Patterns in Programming Design Patterns
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
HW 2 3 UML Class Diagrams Risk Game Framework Risk Game Maker Application Risk Game Application Obviously the two applications will make use of the framework An effective design would minimize the types of objects that would be sent back and forth between the framework and applications called narrow interfaces
Background image of page 2
A root game engine class Ex: Board or Game has access to all game data has public methods to provide key data to external classes (like the application) has public methods to change Risk game state a game application class would have one of these Ex: public class RiskGame extends JFrame { private Board riskBoard // NOW the RiskGame can // manipulate the game
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Project Question How will we render the map showing player ownership? One solution: have 2 BufferedImage objects one to translate mouse clicks that never changes one that we change and display to denote player ownership
Background image of page 4
A possible territory filling algorithm 1. Read .board file, which lists unique colors (r,g,b) for each territory 2. Read .png file and create two BufferedImage objects from this data. One that will be visible and whose territories will change color, one to be used to translate mouse clicks to territories and so will never change. 3. Scan the image data and for each territory, record all pixels that belong to that territory (look for color assigned by .board file). Store all pixel coordinate for each territory (easy to use java.awt.Point class) 4. For visible image, set all territory pixels to neutral color (white, grey, etc ). 5. As a player selects or conquers a territory, change all pixels for that territory in visible image to player color
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Design Patterns Design Pattern A description of a problem and its solution that you can apply to many similar programming situations Patterns: facilitate reuse of good, tried-and-tested solutions capture the structure and interaction between components
Background image of page 6
Why is this important? Using proven, effective design patterns can make you a better software designer & coder You will recognize commonly used patterns in others’ code Java API Project team members Bitter ex-employees
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Common Design Patterns Some we’ll look at today: The Singleton Pattern The Iterator Pattern The Factory Pattern The Flyweight Pattern The State Pattern Later this semester: The Command Pattern and Actions The Observer Pattern
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/10/2008 for the course CSE 219 taught by Professor Mckenna during the Spring '08 term at SUNY Stony Brook.

Page1 / 26

DesignPatterns - CSE 219 Patterns in Programming Design...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online