CSSE 220 – Object-Oriented Software Development

Homework 11

Objectives

Practice recursion.

Tasks

  1. Complete the assigned reading for today's session (Session 11: Big Java, §13.1–13.2 ), according to the course schedule.
  2. Complete the assessment exercise over this reading on ANGEL (under Lessons → Assignments).
  3. Programming:
  4. Solo programming: Complete the following exercises from the Recursion project that you checked out in class. Your solutions to all the following must be recursive.
    1. Complete the isPalindrome() and isPalindrome(int first, int last) methods in the Sentence class of the examples package, if you have not already done so.
    2. Implement, including JUnit tests, the reverse() method in the Sentence class.

      How will you compare two Sentences in your unit tests? Suggestion: compare the text strings by using the Sentence class’s toString() method. (Later we’ll see how to define our own equals() method. Feel free to look up how to do that if you’re interested.)

  5. Sierpiński Triangle. This problem is due as part of HW 12. However, you should make a strong effort to get started on the problem. If you come to class having done the parts you find easy, then you can get immediate help on the parts you find difficult.

    This problem is in the SierpinskiTriangle project that you should check out from your individual SVN repository.

    Complete the recursive drawSierpinski() method in the SierpinskiRenderer class of the sierpinski package. This method should render the Sierpiński Triangle as shown in the figure below. The triangle is rendered by following these steps:

    1. Draw a solid equilateral triangle (like the big solid red triangle behind all those white ones).
    2. In a contrasting color, draw another solid equilateral triangle whose corner points are the midpoints of the original’s sides (like the medium-sized white triangle pointing down in the middle).
    3. Repeat this process recursively for each of the three corner triangles. That is, you will need three recursive calls in your method.
    4. Technically speaking, this process is repeated an infinite number of times to create the true Sierpiński triangle, but we don’t have that much time. So, stop your recursion when the length of a side of the triangle becomes shorter than some fixed constant, say 5.
    Sierpinski Triangle
  6. Pair Programming:

    1. Complete the GameOfLife project that you started in class during session 9. Don’t forget that this is a pair programming exercise.

    2. Together with your teammate:
      1. Complete the TODO items in GameOfLife and GameOfLifeTest. The TODO items are numbered in the order that you should complete them.
      2. Try some different initial configurations. The method getGliderList() in GameOfLifeMain generates a list representing the classic glider formation.
      3. Make sure that:
        • Both team members understand all the code the team is turning in.
        • All methods are documented.
        • All TODO items are completed.
        • No errors or warnings remain.

Remember, in all your code:

Here is the grading rubric for this assignment.

Turn-in Instructions

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