Question: I need help with a homework assignment. Thank you! Please, do not copy and paste from other answers; these answers are not correct, thanks for

I need help with a homework assignment. Thank you! Please, do not copy and paste from other answers; these answers are not correct, thanks for helping.

I need help with a homework assignment. Thank you! Please, do notcopy and paste from other answers; these answers are not correct, thanksfor helping. In this lab, we're going to create a class storinga 2D array and perform some operations with it. Ex. 1. a.

In this lab, we're going to create a class storing a 2D array and perform some operations with it. Ex. 1. a. Table class. Open either Eclipse or NetBeans. Create a project called lab2 and a class called Table inside it. Attributes. Add an instance attribute to this class called maze as a 2D array of type integer. Also add two instance attributes called rows and columns. b. Input c. Randomize and Output To prepare to use a random number generator in Java, import the module java. util . Random. Then declare another static attribute rand of type Random and assign it a new Random( ). equal to the parameter of the function, and if it is, then assign to the cell of the maze the value 1 Add a public method called rawOutput with no parameters and of type void. In this function, traverse the maze array and write all the values out, one row per output line, separated by a space. d. Expanding the Array size, then copy the values from the old array into the new one. The new elements should be 0 s. System. arraycopy() to copy a row at a time from the mazeCopy into maze. In the main, ask the user again for a value for n, then call the method expand with the new size and output the maze again after that to verify that the old values are still there. e. Reading the Table from a File In the main, add a test for this function. You will need to create a text file containing the data in a table as described above first. Place this file in the folder where the Java project is. In this homework, you will continue adding functionality to the class Table created in Lab 2. Ex. 1. Table Class Continue working on the Table class from the project lab2 created in the lab. a. Constructor Add a constructor with a single parameter n, where the maze is initialized as a square array of n-by- n. Call the function init with the appropriate parameters. b. Shrink copied in the call to arraycopy should be equal to the new number of columns. Add an extra test for it in the main. c. Search d. (optional, 3 extra credit points) Pretty Output the elements, check if the value is equal to 0 , and if it is, print a couple of spaces, if it's equal to 1 , then print a character followed by a space, and if it's equal to 2 , print a period (.) followed by a space. For example, if the raw output of the table gives us 101001010100000 100110000001001 then the pretty output of the table should be Hint. For this exercise, the maze itself will not be changed. This is not about replacing the numbers in the table with characters. The numbers remain as they are. e. (optional, 3 extra credit points). Border value 2. You'11 need a loop for the second part. In the main, after expanding the array by calling the method from the lab, call the function makeBorder, then pretty output the array to see the result For example, if you were to call the function makeBorder on a maze that was just printed, the raw output would give you 2220212022 2211000022 2212020222 then the pretty output of the table should be

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!