Honors Programming Assignment 2
Computer Science 102
Using a GUI to display a maze and solving it by recursive
Part A Due Date: WED MAR 21, 11:59 pm
Part B Due Date: SUN MAR 25, 11:59 pm
Use the maze in the following link to generate a maze with blue and white
buttons, where the blue ones represent the walls and the white ones, the
possible path. Solve the maze in a depth-first fashion as shown in class.
Number the buttons consecutively as you numbered the cells in the first honors
assignment. Then use a button listener to drive the movement of the tile on the
direct path to the exit, coloring the tiles pink as you go. The only moves
allowed are N, E, S, snd W.
- Place the maze on a panel in the CENTER of the BorderLayout. Place a panel
on the NORTH of the BorderLayout with a Start button on the WEST of that
panel and instructions on how to proceed displayed in the CENTER of the
panel. Before the Start button is pushed, the orignal maze with blue and
white button should be displayed.
- After the Start button is pushed, the maze display should be the
same as in part a with the buttons used in the depth-first search numbered; but
now a trace button appears on the EAST of the NORTH panel and
instructions on how to proceed is displayed in the CENTER.
- When the trace button is pushed, the buttons on the direct path to
the exit should be colored pink with a 200 second pause between colorings. Use
Thread.sleep() to do this. As this path is traversed, a doubly-linked
list with the steps should be generated as in the second regular assignment (0
should represent a move north; 1, south, etc.) and the path should be displayed
on the NORTH panel.
- When the exit is reached, your program should remove the trace
button -- use remove(trace) dereferencing the NORTH panel to do this --
and insert a retrace button in its place. The message on the panel
should now indicate what to do next. When the retrace button is pushed,
the path to the entrance should be retraced using the same technique as in the
Getting the pause to work is tricky. You have to have a separate thread for
the trace process and one for the retrace process. Nest these in the
if statements detecting an action in the actionPerformed()
method. As an alternative, you can drive the progression of the buttons
down the path by clicking the appropriate button.
WED FEB 28 22:23:14 EST 2007