Project 3

Due date: Friday February 28 (FIRM)

Deadline extended to February 28 due to Project 2 due date of February 7 and test 1 on February 11.

Pair project

If you have not paired up with someone, please do so ASAP, this coming Friday at the latest!


An understanding of
  • Requirements analysis
    • functional requirements
    • nonfunctional requirements
  • Modeling
    • UML class diagrams
    • UML sequence diagrams
  • Design principles and patterns
    • Dependency inversion principle
    • Composite pattern
    • Decorator pattern
    • Visitor pattern
  • Java coding
    • final-correctness
    • @Override correctness
    • anonymous inner classes
    • basic Android graphics
    • mock-based testing using Mockito


In this project, you will complete the implementation of the simple API for drawing graphical shapes. The API design is based on the requirements from the group activity.

See also the practice midterm and its attached solutions, on which this project is based:

See also the expressions and vexpressions examples.

Functional requirements

Start with this code skeleton: functional requirements are embodied in the JUnit tests in the test folder; instructions for running the test are included in the README file. When your code passes all the tests, you will have fulfilled the functional requirements for grading purposes. If some of the tests do not pass, you will receive partial credit. In addition, your app should look exactly like this screenshot:

Nonfunctional requirements

Specifically, complete the code in the various Java source files within the src folder. Look in the Android Studio TODO view for sections marked as TODO or FIXME and use the test cases as your guide. Besides other minor tasks, the main implementation tasks are:
  • Implementing the Size, BoundingBox, and Draw visitors
  • Implementing the missing classes Stroke, Outline, Point, and Polygon
    • The Stroke decorator indicates the foreground color for drawing its shape.
    • The Outline decorator does the opposite of the Fill decorator: it indicates that its shape should be drawn in outline (default) mode.
    • A Point is a location without a shape. You should implement it using a Circle with radius 0 as its shape and override any methods as needed.
    • A (closed) Polygon is a shape defined by a list of points; the last point should be connected to the first. Implement it as a special case of Group.
You must not make any other changes to the code skeleton or the test cases.


  • 0.5 code skeleton intact
  • 0.5 generated JavaDoc (in Android Studio: Tools > Generate Javadoc - use defaults)
  • 1 Size
  • 2 BoundingBox
  • 2 Draw
  • 1 Stroke
  • 1 Outline
  • 1 Point
  • 1 Polygon

How to submit - changed on February 13, 2014

As the first step in working on this project, you or your teammate will push the code skeleton to a private Bitbucket repository shared among the two of you and your instructor and TA. The name of the repository is cs313sp14teamNp3, where N is your team number found in Sakai, and the p3 part refers to Project 3. When your work is ready to be graded, please notify your instructor and TA via both Piazza and Sakai.