Due Thursday, May 17 at 11:59 PM
This lab does not introduce any new material, and it is not required. This is worth bonus points, and has a weight of 4. To put this in perspective, this provides as much bonus as labs 1-4 combined. As such, you are strongly encouraged to attempt this assignment. You do not need to complete the entire assignment to receive points.
The main purpose of this lab is to help prepare you for both the lab and lecture exams. The difficulty of these questions ranges between what would be representative of the exam, along with one step beyond.
Provided files:Zip.java
Pair.java
Fold.java
Map.java
ArrayOperationMain.java
Interleave.java
InterleaveTest.java
collaborators.txt
There are a total of five independent tasks in this lab. These tasks are not evenly weighted. Each is listed below, roughly in order of least to most difficult.
Zip.java
(worth 0.5)This task concerns:
This task requires you to download Zip.java
and Pair.java
.
The comments in Zip.java
provide more details.
Fold.java
(worth 0.6)This task concerns:
You will need to make the program in Fold.java
compile and produce the correct output.
A caveat is that you can only do this by modifying the body of the fold
method, and by defining new files.
The correct output is shown below:
Sum: 18 Product: 240
The code you define in fold
is intended to abstract over the loop pattern shown in Lecture 15.
The intention here is that fold
parameterizes both the initial value to start with (initial
), along with the actual operation performed in the loop (op
).
Map.java
(worth 0.6)This task concerns:
You will need to make the program in Map.java
compile and produce the correct output.
A caveat is that you can only do this by modifying the body of the map
method, and by defining new files.
The correct output is shown below:
---First characters--- f b a b ---Last characters--- o r a h
The code you define in map
is intended to abstract over the loop pattern shown in Lecture 16.
The intention here is that map
will return a new array of the same size as input
, and will fill in each element of the returned array based on a result of op
on a corresponding element of input
.
ArrayOperationMain.java
(worth 1.0)This task concerns:
You will need to make the program in ArrayOperationMain.java
compile and produce the correct output.
A caveat is that you cannot change the contents of that file at all: you can only do this by defining additional files.
The comments in ArrayOperationMain.java
provide additional details.
Interleave.java
(worth 1.3)This task concerns:
Download Interleave.java
and InterleaveTest.java
.
You need to make the code in Interleave.java
compile and produce the correct output.
The comments in Interleave.java
provide more details.
The test suite provided in InterleaveTest.java
should help you write a correct implementation.
This question is more complex than what you can expect on an exam.
Log into Canvas, and go to the COMP 110L class.
Click “Assignments” on the left pane, then click “Bonus Lab”.
From here, you can upload your code.
You should turn in all .java
files needed.
In addition, if you collaborated with anyone else, be sure to download collaborators.txt
and write the names of the people you collaborated with in the file, one per line.
Please submit this file along with the other files.
You can turn in the assignment multiple times, but only the last version you submitted will be graded.