1. Eclipse Debugger

  1. Create a new Java Project in your Eclipse IDE.

  2. Add the code from the Lab2 repo to your newly created Java Project.

The course staff will do a "show and tell" using the Eclipse Debugger.

Practise Exercises
  1. Add tests in ShapeTest that cover all abstract methods in all subclasses of Shape

  2. Use the Debugger to trace through some of the tests. Make sure that

    1. You can explain each step that the debugger makes inside the project code (exclude steps that take you inside the JDK)

    2. You can explain the values that you see in the Variables pane of the Debugger

    3. You can explain the changes in the Debug pane of the Debugger that models the runtime stack

2. Itemizations

The code that you have donwloaded from Lab2 repo

Practise Exercises
  1. Look at the generated method hashCode() inside the class Circle. How does it differ from the generated hashCode() methods from last lab?

  2. Look at the generated method equals(Object o) inside the class Circle. How does it differ from the generated equals(Object o) methods from last lab?

The clients of our shape library would like the following extensions.

  1. All shapes should also have a color. The color is going to be given as an RGB number (8-bit notation). The RGB notation that we would like to use is made of of 3 numbers each number ranges from 0 to 255, e.g. The color white is represented as (255,255,255) the color black is represented as (0,0,0). You can use this website to play around with RGB codes and colors.

  2. All shapes must be able to return their RGB code when called to do so.

  3. Given a shape with an existing color, we should be able to provide a new color and obtain a new shape identical to the original but with its color updated to our new color.

  4. All shapes should also support a shade mode that is one of two statee, shaded or unshaded. We should be able to get the current shade mode of a shape as well alter the mode in the same manner as in the case of color.

Practise Exercises
  1. Implement the preceding requirement. Make sure that you update any classes needed and add tests for each new feature added.

  2. Use the debugger to step through some of the new features that you added. Make sure that you can explain the behaviour and information displayed by the debugger.

  3. Look closely at the implementation of moveX(Integer dx) and moveY(Integer dy) and see if there is duplicated code that could possibly be moved to a superclass. If so make the code changes and ensure that your existing tests still succeed.

3. Adding new items in an Itemization

The clients are now requesting that our shape library deals with right angle triangles. The pin on a right angle triangle is on the corner of the triangle that has the right-angle. To create a triangle we will need to pass

  1. the location of the pin,

  2. the triangle’s base and

  3. the triangle’s height

We would like the library to calculate the hypotenuse of the right-angle triangle. Given a right angle triangle we should be able to obtain

  1. it’s base

  2. it’s height

  3. it’s pin

  4. it’s hypotenuse

We also expect the right angle triangle to behave correctly for each shape operation that we have already discussed and is implemented for the existing shapes (i.e., circle, rectangle and square).

Practise Exercises
  1. Implement the preceding requirements. Make sure that you update any classes needed and add tests for each new feature added.

  2. Use the debugger to step through some of the new features that you added. Make sure that you can explain the behaviour and information displayed by the debugger.

4. Adding more behaviour

The clients would like to replace one shape for another if the shape to be replaced takes up the same area as the shape to be replaced with.

They would also like to be able to test if the area of one shape is greater than the area of another shape, as well as, test if the area of one shape is less than the area of another shape.

Practise Exercises
  1. Implement the preceding requirements. Make sure that you update any classes needed and add tests for each new feature added.

  2. Use the debugger to step through some of the new features that you added. Make sure that you can explain the behaviour and information displayed by the debugger.

5. Composite Shapes

The clients would now like to pair shapes up. The would like a composite shape that is made up of two other shapes. The two shapes can be any valid shape, e.g., two squares, a circle and a triangle etc.

The clients would like to treat this new composite shape just like any other regular shape and support all the operations of shapes that we already have agreed upon.

Practise Exercises
  1. Implement the preceding requirements. Make sure that you update any classes needed and add tests for each new feature added.

  2. Use the debugger to step through some of the new features that you added. Make sure that you can explain the behaviour and information displayed by the debugger.