Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Also, this class must contain the following constant: public static final char EMPTY This constant is set to a space ( ' ' ) The
Also, this class must contain the following constant:
public static final char EMPTY
This constant is set to a space
The class must have the following public methods:
public LetterCrushint width, int height, String initialconstructor
The parameters width and height determine the grid's dimensions, and the
parameter initial is a String of capital letters used to initialize the twodimensional
array grid.
Specifically, the number of rows in grid is given by the second parameter, and
the number of columns is given by the first parameter.
The first "width" characters of the String initial must be stored in the first row of
the grid, the second "width" characters of initial must be stored in the second row
of the grid, etc. If there are fewer characters in the String initial than the number
of entries in the grid, the remaining grid entries are set to EMPTY. If there are
more characters in initial than the number of entries in the grid, the extra
characters in initial are ignored. For example, if width height and initial
"ABAABBAABA", then the first row of grid will store the characters and
; the second row of grid will store and and the last row of grid will
store B A and two spaces.
public String toString
Returns a String representing the characters stored in grid in a format that is
easy to read, that exactly matches the format given below.
new LetterCrush"AACADBBDCD"toString must return
"LetterCrush
DBBD
CD
Note the row number at the end of the to lines, and the column numbers in
the last row. The column indices will always be onedigit values grids with widths
greater than nine will not be tested
public boolean isStable
Returns false if there is any position in grid where a nonEMPTY character is
above an EMPTY character a grid entry with a smaller row than a grid entry with
a larger row in the same column thus, for the example given above in the
description of the toString method, isStable would return false
Otherwise, returns true.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started