CMSI 688
Homework #1
  1. Add two classes, Polygon and DrawablePolygon, to the figures package in the Example Programs of the courseware distribution. Remember, you need not, indeed must not, modify any of the existing source code files in any way!

  2. Construct detailed class diagrams for the figures package in the Example Programs distribution.

  3. Make a UML State Diagram for a simple traffic light. It should switch from red to green when 10 cars back up at it or after 1 minute, whichever is earlier. It should also let all cars which were initially backed up at the red light when the light changed to green proceed through before turning to yellow, although it should not stay green for more than 30 seconds. If this description is ambiguous or unclear or unworkable, propose changes to the problem to make it make sense and write the corresponding state diagram for your improved requirements.

  4. Design an ATM. Don't make it too trivial.

    1. Make a use case diagram for it. Don't forget that not only will customers be depositing, withdrawing and checking balances, but bank employees will be filling it with cash, for example.
    2. Give a sequence diagram for the scenario in which someone uses it to deposit money.
    3. Repeat the previous part using a collaboration diagram.
    4. Repeat the previous part using an activity diagram (with swimlanes). Make the diagram express as much parallelism as possible, even if your design was entirely sequential.

  5. A common pattern that comes up a lot is the need to assign unique identifiers to objects of a given class, for example:

        class Item {
          protected final int id;
          private static int numberOfItemsCreated = 0;
          public Item() {id = numberOfItemsCreated++;}
          // pretend that there are more members here...
        }

    As you can see, every item that gets created will get a unique id. Because this pattern occurs frequently, it might be nice to generalize this and make make something reusable out of it so we don't have to write this code inside every class that needs ids. Perhaps we need an interface or abstract class. Tell me why these two suggestions won't work (with a detailed, technical answer)! Then tell me something that will work. (Note: there is nothing wrong with the access modifiers above; the problems with my two suggestions have to do with the nature of interfaces and abstract classes.)

  6. Make a state diagram for an elevator. Before you start make a list of all the states, actions, activities, events and transitions.

  7. Make a class diagram relating Insurance companies, insurance policies, insurance contracts and customers.

  8. Make an activity diagram for a vending machine use case called "Buy Item." Note there are a lot of things that can go wrong. Also note a user can cancel an operation part way through.

  9. Read a chapter from an OO textbook or reputable website entitled something like "Finding Classes." Finding classes refers to how one comes up with the proper classes from system requirements. Write a one- or two-page summary in well-organized, spell-checked, grammar-checked English highlighting some tips and strategies, and some "dos and don'ts." Make sure someone reading your paper will learn something.

  10. The Gang of Four's design patterns book uses OMT, not UML. "Port" the following diagrams to UML: Page 208, Page 107, Page 74, Figure B.3. Also give the Collaboration Diagram equivalent to the sequence diagram for Figure B.3.