Project 3

Due date: Friday July 7 (FIRM)

Pair project

If you have not yet paired up with someone, please do so by June 19 at midnight!


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 an in-class group activity.

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

See also these examples: expressions (how to process simple arithmetic expressions) and vexpressions (how to do the same with visitors / the Visitor design pattern).

Functional requirements

Start with this code skeleton: functional requirements are embodied in the JUnit tests in the test folder; instructions for running the tests are included in the README file and in the Notes below. 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 produce an output that looks exactly like this screenshot: when run on an emulator or Android device.

  • See below under How to submit for how to name your imported Bitbucket repository (this uses the standard course naming convention).
  • Use Android Studio to check out your imported Bitbucket Project
    • Android Studio may tell you that the Project is missing its "VCS root" when it opens it - be sure to click the link that tells Android Studio to connect the VCS root automatically, otherwise you will not be able to push changes back to your Bitbucket repository
  • Although the README file says you can use Android Studio to run the Unit tests, it's safer to use Gradle to run them: click on Terminal at the bottom of the Android Studio window and type gradlew testDebug on a Windows PC or VM, or ./gradlew testDebug on a Mac or on Linux

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 one to close the Polygon. 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 the defaults)
  • 1 Size
  • 2 BoundingBox
  • 2 Draw
  • 1 Stroke
  • 1 Outline
  • 0.5 Point
  • 1 Polygon
  • 0.5 output from running your app on an emulator or real device should match the drawing shown in the link in the Functional Requirements section above
    10 points total

How to submit

As the first step in working on this project, you or your teammate will import the code skeleton into a private Bitbucket repository shared among the two of you and your instructor. The name of the repository is cs313413su17teamNp3, 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 via either Piazza or Sakai.