{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

DesignPatterns - CSE 219 Patterns in Programming Design...

Info icon This 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
Image of page 1

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

View Full Document Right 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
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
Image of page 3

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

View Full Document Right 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
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
Image of page 5

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

View Full Document Right 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
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
Image of page 7

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

View Full Document Right 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:
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern