CSSE 220 – Object-Oriented Software Development

Homework 5

Objectives

Practice creating, documenting, and testing classes based on a given public interface. More graphics and math practice.

Tasks

  1. Complete the assigned reading for the next session: Chapter 4. (See schedule for topics to focus on.) As you read, see if you can answer the self-check questions. If there is something you do not understand, make note of it so you can ask about it.
  2. Complete the assessment exercise over this reading on ANGEL (under Lessons → Assignments).
  3. Programming:
    1. Your programming work for this assignment must be done in the ImplementingClasses project inside Eclipse. Use the SVN Repository Exploring perspective to check out this project, then switch back to the Java perspective.

    2. Update the Face class that we began together:
      1. Add a parameter to the constructor to set the angle of the face in degrees. Add and initialize a field to store the angle. Be sure to update the javadocs for the constructor.
      2. Change FacesComponent to pass an angle in each constructor call.
      3. Change the drawOn() method so the eyes and mouth are drawn correctly based on the stored angle. See the examples below for faces drawn at various angles.
      4. Add three methods to Face:
        • public void setAngle(double angle)
        • public double getAngle()
        • public void rotate(double degrees)
        The methods should do what their names imply. Be sure to document your methods before implementing them. Also be sure to add unit tests to FaceTests.
      5. Change FacesComponent so it draws faces rotated 30° each as in the figure below.
      Sample output of FacesComponent with faces rotated 30 degrees each
      Faces starting at 0° and rotated 30° for each successive face.
    3. Complete Exercise P3.5 from Big Java. Use JUnit to implement the required CarTester class.

      This exercise doesn’t involve graphics. You’ll just implement and test a Car class that models fuel economy. The objective is to practice with the “How To: Implement a Class” steps from session 5.

Turn-in Instructions

Turn in your programming work by committing it to your SVN repository.