Project 3

Due date: Friday October 21 (FIRM)

Pair project

If you have not yet paired up with someone, please do so by September 23 (September 27 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 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).
  • You can use Android Studio to check out your imported Bitbucket Project, not Git Bash on Windows
    • Be sure to click any link that comes up to connect the Project to Gradle, otherwise it won't be connected to Gradle properly (I was not able to get that to work when I used Git Bash on Windows, which is why I'm suggesting that you use Android Studio to do the checkout). 
    • You need to connect the Project to the latest version of Gradle that you downloaded and unzipped to your PC - on my Windows PC this was Gradle version 2.6, which worked fine. The path for Android Studio to use is the the path to the gradle-2.6 folder, that is, somewhere/gradle-2.6 (somewhere being wherever you unzipped Gradle)
  • Android Studio may tell you that the Project is missing its "VCS root" when it opens it - click the link that tells Android Studio to connect the VCS root automatically.
  • The README tells you to run gradle unittest in an Android Studio Terminal Window in order to see the test results. However, you may have to type the full path to gradle in the Terminal window to get the tests to run, for example: somewhere/gradle-2.6/bin/gradle unittest.

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 and TA. The name of the repository is cs413f16teamNp3, 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.