Bug Variations

Create a new project named BugVariations. Copy and paste the code from the BugVariations demo program. Add the following classes that extend Bug to the file. Be sure to space out each new bug in a unique color on the grid so the instructor can easily grade the project. Delete any unnecessary classes that were provided in the BugVariations demo program and edit the main method in the client class so that the bug objects are instantiated and used in the order specified above.

Your code and algorithms should be as efficient as possible. Your program must follow our class Coding Standards even if code that you have copied from demo programs or the College Board material does not follow the Coding Standards. Your program will be graded partly on style.

  1. BouncingBug - goes up and down vertically over and over again tracing a line segment. The length of the line segment is determined by the int parameter of its "other" constructor.

  2. RandomColorBug - moves like a BoxBug but changes to a random color each time the act method executes. It should use at least 4 random colors that you can choose from the Java Color class. You may have to import the Color class.

  3. HopAroundBug - moves to a random location within an imaginary square framed by (0, 0) and (10, 10) each time the act method executes.

  4. DisappearingBug - moves like a BoxBug but has a certain percentage chance of disappearing each time the act method executes. The percentage is specified as an int parameter to its "other" constructor (e.g. 40 would mean that it has a 40% chance of disappearing each time the act method is called).

  5. CrazyBug - moves like a Bug except that it moves in any of the eight random directions around it each time the act method executes.

You must hand in the following on separate pages stapled in this specified order:

    1. The source code for the BugVariations class that includes the bug classes listed above in the order specified above. Delete any unnecessary classes that were provided in the BugVariations demo program and edit the main method in the client class so that the bug objects are instantiated and used in the order specified above.

    2. Call the instructor to your computer in order to have him do a runtime grade for this project.