Project 1b

Due Date: Mon 10 Oct (firm!)

Individual Project

Objectives

An understanding of
  • More Scala programming
  • An algebraic view of recursive data types and its limitations
  • Mutual recursion
  • More end-to-end, test-driven development (TDD) in Scala and Eclipse

Description

Please check out a copy of shapes-algebraic-scala. There will be some syntax errors and runtime errors. 

You may temporarily move all sources with "Extended" in their names out of the project. Then TestShapeSize and TestShapeValidity should pass out of the box, as should some of the TestBoundingBox cases.

Then perform the following modifications, generally indicated with TODO in the sources themselves:
  1. (1 point) In src/.../shapeAlgebras: add the missing case in BoundingBox.
  2. (2 points) In src/.../Draw: add the missing cases for Location and Group. The test suite TestDraw should now pass.
  3. (5 points) In src/.../moreShapes: define the missing additional shapes. The compile-time errors in TestFixturesExtended should now disappear.
  4. (2 points) In src/.../ExtendedShapeAlgebra: add the missing visit methods and cases in the fold method similarly to Location in ShapeAlgebra.
  5. (6 points) In src/.../extendedShapeAlgebras: 
    • ExtendedShapeSize: explicitly forward the visit methods for the original shapes at the object level (see example).
    • ExtendedShapeDepth: implement all visit methods from scratch.
    • ExtendedBoundingBox: inherit the methods for the original shapes at the class level (without explicit forwarding). Approximate the bounding box of a rotated shape by rotating the bounding box around its anchor point.
  6. (4 points) In src/.../ExtendedDraw: add the missing cases for those additional shapes (excluding Point, which does not need to be handled specially). As discussed in class, rotate a shape around the anchor point of its bounding box; the corresponding branch of ExtendedDraw should draw the rotated shape accordingly. The test suite TestExtendedDraw should now pass.

Total: 20 points. Partial credit is given as appropriate.

Extra Credit

Extra credit is given for 
  • Implementation and testing of an additional affine transform such as scale or shear. More details are found here.
  • Written discussion of the dependency of ExtendedDraw on bounding box calculation. How can this dependency be managed so as to enable the addition of future shapes not handled by BoundingBox or ExtendedBoundingBox?

References

Submission

Please refer to the online submission procedure.
Comments