(Recursion (Recursion (Recursion (Recursion))))
Key:
Shell.java
This file was used in
previous assignments. (Do not modify)Recursion.java
. This
defines the interface of the public
methods you will write.
It also contains code for testing your methods.
(Do not modify) MyRecursion.java
. This
is the file you will complete. It is likely that you will write additional
private
helper methods to complete the work. No java loop
constructs are allowed in this file! All work must be done using recursion
. Nor may you add additional classes with methods that use loops.
You may not use the ArrayList.contains()
method.
SampleFile.java
.
This is a simple program to show you how to use several methods of the
File
class that you will use in your assignment. You will
not actually use this class in your solution, but you should compile and
run it to understand how to do various operations on files and directories.
Here is the documentation for the classes. Study the documentation for details on how to complete your implementation.
Save target as ...
to save this file in your project.
SampleFile
class and run it to see it works.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
.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.contains()
method. This will be quite
similar to the list()
except it will check if each element
matches the one being searched for.intersect()
method. You should find that
the contains()
method is useful here.diamond
method. Look at the symmetry of the
output (horizontal and vertical) and see if you can exploit that.directory()
method. This will combine
calls to various recursive methods.
MyRecursion.java
using the Checkin tab of
the course website. Alteratively, at a terminal, type
~csXXX/bin/checkin XXX MyRecursion.java.