For this assignment we model functions of one variable with an interface,

/** Functions of one variable. */ public interface Function1<X> { /** Apply the function to a value. */ public X apply(X arg); }

We can imagine a class `MandelbrotBase`

for the function *f _{c}(x)=x^{2}+c* underlying the Mandelbrot set: it would implement

`Function1<Complex>`

, and its constructor would take a complex value for *c*,

public class MandelbrotBase implements Function1<Complex> { public MandelbrotBase(final Complex c) { // ...

Implement a test class `MandelbrotBaseTests`

to test the `MandelbrotBase`

class.

For the Mandelbrot set we must consider the application of a function several times to its own result, so we can also imagine a generic class `Function1Iterator`

to generate the sequence of values arising from successive applications of a function,

public class Function1Iterator<X> implements Iterator<X> { public Function1Iterator(final Function1<X> f, final X initial) { // ...

The first value returned by the `next()`

method of a `Function1Iterator`

should be `initial`

, and then the result of `f.apply(initial)`

, then `f.apply(f.apply(initial))`

, and so on. Implement a test class `Function1IteratorTests`

to test an implementation of `Function1Iterator`

. Since we can always apply `f`

another time, `hasNext()`

will always return `true`

.

**Submission instructions**. Your work should be submitted as a ZIP archive containing a `src`

directory with the four single plain-text files `MandelbrotBase.java`

, `Function1Iterator.java`

, `MandelbrotBaseTests.java`

and `Function1IteratorTests.java`

. It is due to the AutoLab server by **8:30am** on November 1.

- Important note: do not include in your
`src`

directory a folder named`Lib`

, or any file whose name starts with`Autolab`

. All such files will be ignored when your work is copied to AutoLab’s work directories for compiling and running.

*How this assignment will be evaluated.* Submssions of code and tests **at the same time will be scored as the product** of three ratios:

- The percentage of your tests which your code satisfies
- The percentage of my tests which your code satisfies
- The percentage of my implementations which your code correctly diagnoses.
- To correctly diagnose a bug-free implementation, all of your tests must pass (and there must be at least one such test). Correctly diagnosing bug-free implementations will count for no less than one-third of this ratio.
- To correctly diagnose an implementation with a bug, at least one of your tests must detect it and fail. Note that tests which always fail are not considered to detect problems! Any test which fails for all non-exception-throwing implementations will be disregarded here.

Note that all code and tests will be compiled together — so if your code does not provide the API which my tests expect, you will not be able to earn points on this assignment!

**Avoid plagiarism.** The course syllabus has further details about our expectations of academic integrity. In particular: You may not copy code from any other source and claim it as your own. You may not share any of your code with any other student for use in completing any of these assignments.

See also: Assignment 3.x general information, CS220 homepage