Answered step by step
Verified Expert Solution
Link Copied!

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 LetterCrush(int width, int height, String initial)[constructor]
The parameters width and height determine the grid's dimensions, and the
parameter initial is a String of capital letters used to initialize the two-dimensional
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 =4, height =3, and initial =
"ABAABBAABA", then the first row of grid will store the characters A,B,A, and
A; the second row of grid will store B,B,A, and A, 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(4,3,"AACADBBDCD")).toString() must return
"LetterCrush
|AACA|0
|DBBD|1
|CD 12
+0123+
Note the row number at the end of the 2nd to 4th lines, and the column numbers in
the last row. The column indices will always be one-digit 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 non-EMPTY 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.
image text in transcribed

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

Recommended Textbook for

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions

Question

What are five common reasons for systems projects?

Answered: 1 week ago

Question

4. What are alternative methods for building information systems?

Answered: 1 week ago

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago