Question: /* Hi, I have a Java Linked List problem. * * Say I have the node class: */ public class GridNode { private GridNode right;
/* Hi, I have a Java Linked List problem.
*
* Say I have the node class:
*/
public class GridNode
{
private GridNode right;
private int data;
private GridNode down;
public GridNode(GridNode down, int data, GridNode right) {
this.setDown(down);
this.setData(data);
this.setRight(right);
}
public int getData() {
return data;
}
public void setData(int data) {
this.data = data;
}
public GridNode getRight() {
return right;
}
public void setRight(GridNode right) {
this.right = right;
}
public GridNode getDown() {
return down;
}
public void setDown(GridNode down) {
this.down = down;
}
}}
/*
Then I have another class called "Grid" whose constructor will link these nodes like a grid.
Note: The node class has two pointers, a RIGHT and DOWN.
The RIGHT pointers will link the nodes to the right of it to make a row and
the DOWN to make the columns.
Also, make the final node created point to the first node in the row/col to make it circular.
THE PROBLEM:
Initialize the grid structure mentioned in the "Grid" constructor with parameters (6,10).
Also a method that lets you insert a whole row or column to the grid after its made and a delete method.
*/
Diagram of the constructor:

public class Grid
{
GridNode head;
public Grid(int row, int col)
{
//set up a 6 by 10
}
public void insert(){
}
Public void delete(){
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
