For this assignment you are to create a button-controlled flying saucer program. The buttons in the panel displayed below control the saucer, allowing it to move up, down, left and right. When the saucer reaches the ground, it breaks apart into hundreds of randomly generated pieces. Your specification for the project is the embedded display you see below.
Note: Because of set-up details the Quit button does not work here, but should work in your implementation.
The driver and DisplayWindow classes, which you must use and which you may not alter are provided here:
The DisplayWindow class is the same as the DisplayWindow class that figures prominently in Chapter 12 of the textbook.
For this assignment you are to submit a single file, SaucerPanel.java (must be so named), which extends JPanel in the standard way, and which carries out the main actions of the assignment. That is, your solution:
1) must include the five controlling buttons shown in the demonstration panel;
2) must include the “hovering…” tag, as shown, which follows the saucer around;
3) must break apart into 400 pieces when the saucer reaches the ground. The “pieces” must be circles of diameter 6, and these must be generated at random positions using methods from the Random class.
Also, the city view provided above, with its two-building skyline, is pathetic. Feel free to make improvements to the city scene we've provided!
Submit your code in the box below. Note that we provide the necessary import statements; do NOT include import statements in your pasted version, and of course do not use any classes in your solution that are not imported by the import statements we've provided.
For this project you must comment your code.
import java.util.Random; import java.awt.*; import javax.swing.*; import java.awt.event.*; // needed for event handling
//insert code here