(Recursion (Recursion (Recursion (Recursion))))


Essentials

Due:

Key:


Overview

In this assignment you will complete one class. The assignment is structured like the previous assignments, but does not build on them. You will learn to write recursive methods. The assignment consists of four files:

Here is the documentation for the classes. Study the documentation for details on how to complete your implementation.


Getting started

There is a lot to do in this assignment (understanding recursion), but if you do the work logically and incrementally, you will save time. Here are a few suggestions to get you going.
  1. Set up your project and add the provided code (the classes described above). The easiest way to do this is to right click the link and use Save target as ... to save this file in your project.
  2. Use the IDE to generate stubs for the abstract methods.
  3. Study the SampleFile class and run it to see it works.
  4. In the MyRecursion implement the repeat() method. This is a simple problem of replacing a loop by recursion. Look at how this is done in the lecture notes. Test it using repeat.
  5. Next, implement the list() method. Again you will be doing work using recursion. This time you will be dealing with an array of data. This is a learning experience for later on.
  6. Next, implement the contains() method. This will be quite similar to the list() except it will check if each element matches the one being searched for.
  7. Next, implement the intersect() method. You should find that the contains() method is useful here.
  8. Implement the diamond method. Look at the symmetry of the output (horizontal and vertical) and see if you can exploit that.
  9. Finally, implement the directory() method. This will combine calls to various recursive methods.
  10. Congratulations, you are done!, Turn it in and relax.

Submitting Your Assignment

Check in the single file MyRecursion.java using the Checkin tab of the course website. Alteratively, at a terminal, type

  ~csXXX/bin/checkin XXX MyRecursion.java
.