View
 

Lab 15: Solar System 3

Page history last edited by Mr. Kretsch 4 months ago

Name: __________________

Objective: Overloaded Methods

Instructions:

 

  1. Import the files from Lab 15 Solar System 3. You will be importing a new applet file
  2. Modify your Rock and Gaseous classes as follows
    1. Create a second constructor that creates the planet at a random location on the window. 
    2. Create a second move method that moves the plant to a random location. Ditto.
  3. Modify the applet as follows
    1. At the start of the program, create  a Gaseous planet at (100, 100), and a Rocky planet at (200, 100).
    2. If the user clicks on a planet, move it to a random location.
    3. 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

  1. 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   
 
Second rocky constructor  
 
Second Rocky move  
 
Second Gaseous move  
 
Applet behavior  
 
Extra Credit  
 
    14  

 

Notes

 
 
 
 
 
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Lab Instructions

Objective:

Building a class from and abstract class and an interface.

Getting Started

  1. Open your SolarSystem project.

  2. 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

  1. 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.

  2. Modify the applet code in Lab25Applet to do the following.

  3. One of each planet type, and a spacecraft, but do not start the animation until…

  4. The first time the user clicks on the window, at which point start the spacecraft and comet.

  5. For all subsequent clicks, change the spacecraft to travel in the direction of the clicked location.

Wrap-up

  1. Hand in your grade sheet.

3 of 3

Comments (0)

You don't have permission to comment on this page.