Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with implementing the following Java class: 3.3 class Grid This class represents a two-dimensional ArrayList of some type of value. We will use

Please help with implementing the following Java class:

image text in transcribed

3.3 class Grid This class represents a two-dimensional ArrayList of some type of value. We will use a few different kinds of grids in the project; this will help you avoid lengthier types like List> 3.3.1 fields * public ArrayList values. We've enforced use of ArrayList, just go with it. 3.3.2 methods public Grid(int numRows, int numcols). Creates a Grid of the indicated size, with null at each location * public Grid(T[]1] ingria). Assumes the input is rectangular, and creates/fills the values field from its contents public int height). Returns number of rows publci int width). Returns number of columns * public T get(int i, int j). Returns the item in row i and column j. This is a two-for-one indexing operation * public void set(int i, int j, T value). Assumes that location (i,j) exists in the Grid, and sets that location's value to the given value * public T remove(int i, int j). This method performs two actions: first, it tries to remove the item at location (i,j). It also checks if the indicated row is now empty, and removes it when it is. Lastly, the removed value is returned public Grid transpose ( ) . Creates and returns a transposed version of the Grid (the original leftmost column is the new first row; second-leftmost original column is the new second row; etc). Doesn't modify the original * public string tostring). Let's be lazy, and just return whatever values.tostring() looks like public boolean equals (Object other). When other is also a Grid, and both grids are the same size, and every single location holds items that are .equals()-equivalent to each other, this method returns true. (false, otherwise) 3.4 class Node This class is strongly encouraged to be used when finding the cheapest vertical/horizontal path. We will create a Grid, initially with a lot of null's/zeroes in it, and then from the bottom up, fill in the details. Each Node knows where it is (Point p); eventually knows which of the three candidate nodes below it is best (storing a null until this is calculated); and knows the full cost from itself all the way down to the bottom

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions