Lab 17: More Multidimensional Arrays and fail()


Due Monday, December 5 at 11:59 PM

Goals for This Lab

By the time you have completed this work, you should be able to write programs which:

Provided files:

Step-by-Step Instructions

Step 1: Edit SwapMultidimensional.java

Download the SwapMultidimensional.java file, and open it in jGrasp (or a text editor of your choice). This program contains two methods which you will need to write:

main contains some code which will call swapRows and swapCols, for the purpose of informal testing. With this in mind, example output of the program is below:

Before swapping rows 0 and 2:
0 1 2
3 4 5
6 7 8
After swapping rows 0 and 2:
6 7 8
3 4 5
0 1 2

Before swapping columns 1 and 2:
9 8 7
6 5 4
3 2 1
After swapping columns 1 and 2:
9 7 8
6 4 5
3 1 2

Step 2: Open SwapMultidimensionalTest.java as a Test File, and Edit It

Download the SwapMultidimensionalTest.java file, being sure to put it in the same folder/directory as your SwapMultidimensional.java file. Open this file in jGrasp as a test file, using the same instructions you've used in previous labs. This time around, you have been provided will all the tests, though you may add your own if you wish. However, you will need to define the assert2DEquals method in the test suite in order to make the provided tests actually do anything meaningful. The comments in SwapMultidimensionalTest.java provide more details.

Step 4: Turn in Your Solution Using Canvas

Log into Canvas, and go to the COMP 110 class. Click “Assignments” on the left pane, then click “Lab 17”. From here, you can upload your answers and your code. Specifically, you must turn in the following two files:

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 two files.

You can turn in the assignment multiple times, but only the last version you submitted will be graded.