can u please help me.. with my two dimensional array - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

can u please help me.. with my two dimensional array

terradojamesterradojames Posts: 1Member
[size=4][/size]Consists of three classes: Blob, GridPoint, and Grid.
Blob has two fields: colour (String) and weight (double). The Blob constructor has no
parameters. It initializes the fields to randomly-chosen values. Possible colours are
"red", "green", "yellow", "blue". Possible weights are between 0.0 and 100.0.
GridPoint has two int instance variables, row and column. These will be used to refer to
positions on a two-dimensional grid. Pass both to the constructor.
Grid has one instance variable, a two-dimensional array of Blob objects. The Grid
constructor will have two parameters specifying the number of rows and columns in the
Grid object, and will create a new Grid of the appropriate dimensions.
Provide the following methods:

/* Loads the grid with references to new Blob objects */
public void loadGrid()
/* Displays the grid contents */
public void displayBlobs()
/* Searches the grid for the first Blob with the specified
colour and returns the coordinates as a GridPoint object or
returns null if not found. */

public GridPoint getCoordinates(String colour)

Sample output from displayBlobs()
Blob at 0 0 : red 81.99239749504676
Blob at 0 1 : green 60.43769240862219
Blob at 0 2 : blue 7.165859648185602
Blob at 1 0 : blue 74.42287084927185
Blob at 1 1 : blue 59.198789598652546
Blob at 1 2 : blue 57.26935281234613


With the grid loaded as above, a call to getCoordinates(
Sign In or Register to comment.