| |
Lab 15: Solar System 3
Page history
last edited
by Mr. Kretsch 4 months ago
Name: __________________
Objective: Overloaded Methods
Instructions:
- Import the files from Lab 15 Solar System 3. You will be importing a new applet file
- Modify your Rock and Gaseous classes as follows
- Create a second constructor that creates the planet at a random location on the window.
- Create a second move method that moves the plant to a random location. Ditto.
- Modify the applet as follows
- At the start of the program, create a Gaseous planet at (100, 100), and a Rocky planet at (200, 100).
- If the user clicks on a planet, move it to a random location.
- If the user clicks on the background, instantiate a planet at a random location.
Design Considerations
- In the second constructor and the second move, the random location is chosen by the constructor and method, not by the client..
- Make sure the randomly generated coordinates are valid.
Extra Credit
- Create a third constructor for Rocky that generates a planet at a random location with a limited random size. When the mouse enters the window, use this constructor to instantiate a new Rocky planet
Grading
| Feature |
Points |
Out of |
Notes |
| Second Gaseous constructor |
|
2 |
|
| Second rocky constructor |
|
2 |
|
| Second Rocky move |
|
2 |
|
| Second Gaseous move |
|
2 |
|
| Applet behavior |
|
6 |
|
| Extra Credit |
|
2 |
|
| |
|
14 |
|
Notes
Lab Instructions
Objective:
Building a class from and abstract class and an interface.
Getting Started
-
Open your SolarSystem project.
-
Import the files from R:\AP Java\Projects\Lab 25 SolarSystem 4. The file you will be importing is the Lab25Applet applet class, and three new classes Spacecraft, Steerable, and Vector. Documentation for these classes is attached.
Assignment
-
Create a new Spacecraft class that is steerable. The class name is up to you. The graphical representation of the object is also up to you. However, the class must be animated and used the Vector class to move in a diagonal direction and bounce off the walls in the correct angle.
-
Modify the applet code in Lab25Applet to do the following.
-
One of each planet type, and a spacecraft, but do not start the animation until…
-
The first time the user clicks on the window, at which point start the spacecraft and comet.
-
For all subsequent clicks, change the spacecraft to travel in the direction of the clicked location.
Wrap-up
-
Hand in your grade sheet.
Lab 15: Solar System 3
|
|
Tip: To turn text into a link, highlight the text, then click on a page or file from the list above.
|
|
|
Comments (0)
You don't have permission to comment on this page.