CSSE 220 – Object-Oriented Software Development

Homework 12

Objectives

Practice with designing and implementing classes.

Tasks

  1. Complete the assigned reading for the next session: §9.1–9.5. (See schedule for topics to focus on.) As you read, see if you can answer the self-check questions. If there is something you do not understand, make note of it so you can ask about it.
  2. Written exercises: You may write your answers to these questions neatly on paper, or type and print your answers if you prefer. Sketches can be done on paper, or using a drawing program of your choosing. (I suggest the former unless you already know a drawing program well.)
    1. Suppose you were going to implement a program to let two people play chess against each other. Think about what classes you would need. (Search on-line to find the rules of chess if you aren’t familiar with the game.) List all the classes that you can think of that might be useful in implementing your program. For now you can assume that users will enter moves in the console, but you’ll display the board in a graphics window.
    2. From your list of potential classes, decide which ones you would use in an actual implementation. Pay particular attention to the rules for good classes that we discussed in class. Sketch a UML class diagram for your classes. Show the public interface of each class and the dependency relationships between the classes. Recall that dependency relationships are indicated by dashed lines with open arrow heads.
    3. Write a couple of paragraphs explaining why you chose the classes that you did for your design. Discuss the cohesion and coupling of your classes.
  3. Programming:
    1. Your programming work for this part must be done in the DesigningClasses project inside Eclipse. Use the SVN Repository Exploring perspective to check out this project, then switch back to the Java perspective.
    2. Create classes based on your design for Chess. Create constructor and method stubs for your design and add javadocs. You do not have to actually implement the constructors and methods at this time, though you may do so if you find that interesting.

Turn-in Instructions

We will grade your Wiki contributions using ANGEL. Turn-in your programming work by committing it to your SVN repository.