[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(
0 · ·