Initial project folder you will see the beginnings of a


Shooting Star

A Block and DoubleListOfBlock classes. You need to implement that DoubleListOfBlock methods so they perform according to the specifications (pre and post conditions). You can choose to use sentinels and pre-pointers or not, but the given methods are all that should be in the DoubleListOfBlock class. The Block class inherits JComponent to create objects that (when added) produce filled 10 by 10 squares whose color can be assigned by setBackground.

Your Driver class must implement a black JFrame and two JButton objects - one called Grow and Shrink. Note that by implementing ActionListener and calling addActionListener, your Driver can create and handle events for its own JButtons. Driver must also manipulate four DoubleListOfBlock objects -- a horizontal list, a vertical list, a major diagonal list and a minor diagonal list. All three lists are spread, centered, across the JFrame as their names imply and pictured below:

1069_Star.png

Initially, all that is visible of the four lists are four randomly-colored blocks in the center of the JFrame. Each click of the Grow button causes all four lists to grow by two Blocks from its center, thereby "pushing" the prior blocks outward by 10 pixels. All four lists must insert the same randomly-selected color as their new center Blocks.

Each click of the Shrink button causes all four lists to shrink by removing their centermost two Blocks. Both Grow and Shrink operations update the JFrame to be consistent. (You can observe this behavior in the sample applet on Riley's website.)

Selecting a random color is best accomplished by creating a java.awt.Color object and passing the Color constructor three random int parameters in the range from 0 through 255. (Math.random() returns a double in the range from 0.0 up to but not equal to 1.0.)

Using the java.awt.event.MouseListener interface, cause your Block objects to handle events in the following way. Every time that a Block is clicked, that Block and all other Blocks equidistant from the center of the four lists are all colored white.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Initial project folder you will see the beginnings of a
Reference No:- TGS0820130

Expected delivery within 24 Hours