Question: import java.lang.reflect.Array; import java.util.ArrayList; public class LinkedGrid { protected int numRows; protected int numCols; protected GridNode head; protected GridNode lastRowHead; protected GridNode lastColHead; public LinkedGrid
import java.lang.reflect.Array; import java.util.ArrayList; public class LinkedGrid protected int numRows; protected int numCols; protected GridNode head; protected GridNode lastRowHead; protected GridNode lastColHead; public LinkedGrid A constructor which takes the initial number of rows and columns of the LinkedGrid. This constructor needs to initialize the LinkedGrid with grid nodes which are initially empty Example: if I invoked the constructor with new LinkedGrid then I would have to initialize my LinkedGrid of empty nodes with rows and nodes per row public LinkedGridint numRows, int numCols TO DO this.numRows numRows; this.numCols numCols; createGrid; public GridNode handleEmptyGrid Constructor which takes a normal D array as an argument. This is the ONLY place you can use a D array and this D array is only used to initialize the values of your LinkedGrid object public LinkedGridE elements TO DO this.numRows elements.length; this.numCols elementslength; Get the number of rows public int getNumRows return numRows; Get the number of columns public int getNumCols return numCols; Returns the item at the given row col NOTE: You must return the item stored in the GridNode, NOT the GridNode itself public E getint row, int col GridNode curr head; forint i ; i curr head; forint i ; i getRowint index ArrayList rowValues new ArrayListgetNumCols; GridNode curr head; forint i ; i getColint index ArrayList colVaules new ArrayListgetNumRows; GridNode curr head; forint i ; i index; i curr curr.nextCol; forint j ; j
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
