Q7: Extending Bubbles

Table of Contents


  • Learn about colors and transparency.
  • Practice using loops to position objects.
  • Make use of arrays to position objects.
  • Use pair programming to solve problems.

Academic Honesty

Read the Scholastic Honesty Policy and Assignment Integrity policies of the syllabus. Here are some clarifications for this particular assignment:

  • You are expected to work with one other student of this class following the rules of Pair Programming for Homework Assignments.
  • You may copy small portions of the code from the textbook or the instructor's web pages.
  • You may get help from people other than your pair-programming partner if you get stuck, but only if they do not show or tell you the code to type. Instead they should show you other examples that you can adapt to your code.
  • Do NOT copy or modify code from, nor provide code to, any other student or unauthorized source.
  • Do NOT give a copy of your code to your designated pair-programming partner if you did not develop the code together.

Project Crafting Specifications

This project is based on a scenario from the end of chapter 6 in the textbook.

  1. Work with one other student following the rules of Pair Programming for Homework Assignments.

    If you cannot find a partner, talk to the instructor right away. If there are an odd number of students, the instructor may assign one group of three students.

  2. Start with the completed bubbles scenario we worked on in class, or the scenario from the end of chapter 6 in the textbook if you do not have the in-class scenario.
  3. In the world subclass, create a new private method named setup(). Call this method from the constructor. In this method, create a new bubble, using the default constructor of Bubble, and place it in the middle of the world.

    The prepare() method is not needed or allowed, so remove it if you have one.

  4. Add a while-loop to the setup() method that places 11 bubbles randomly in the world.
  5. Add a for-loop to the setup() method that creates 21 bubbles along a diagonal with an x and y distance of 30. The first bubble at (0,0), the next at (30, 30), then (60, 60), and so on. The last bubble will be at (600, 600) for 21 bubbles.
  6. Add a second for-loop to the setup() method that places 12 bubbles on a horizontal starting at x=200, y=100, with x increasing by 40 each iteration and y remaining constant at 100. Thus the first bubble is at (200, 100), the next at (240, 100), then (280, 100), and so on. The size of the bubble must increase as well, stating with a size of 10 for the first bubble and increasing in size by 10 each iteration of the loop. Use the Bubble constructor with one parameter to set the size.
  7. Add a third for-loop to the setup() method that creates 19 concentric bubbles at the center of the world. The bubbles start with a size of 190, decreasing by 10. The last bubble has a size of 10. Make sure to create the largest bubble first and the smallest last, so you have bubbles of sizes 190, 180, 170, and so on , all lying on top of each other.

    Use the constructor of Bubble with two parameters to set the initial direction (see exercise 7.4 step 5). Set the direction of the first bubble at 0, the second at 20, the next at 40, and so on. Notice that the direction of each subsequent bubble is increasing by 20 degrees. When the scenario runs, these overlapped bubbles expand outwards in all directions from the center of the world.

  8. Add two integer arrays, one named xDiag and the other named yDiag, to store the (x, y) coordinates for positioning bubbles from the upper right-hand corner of the screen to the lower left-hand corner of the screen. Create and position 24 bubbles and make sure each array has 24 elements. Use a for-loop to read the coordinates for the position of each bubble.
  9. Update the Scenario Information (README.TXT file) for your project to fill in all the Greenfoot supplied information like your name, project title and version or date, as well as providing the current status. Include the name of your pair-programming partner. Even though the project file may not include the usual labels, like those shown below, please add them.
  10. PROJECT TITLE: Bubbles
    PURPOSE OF PROJECT: Draw bubbles at specified positions.
    HOW TO START THIS PROJECT: Press run after compiling,
    AUTHORS: Your Name (and Pair Programming Partner)
    USER INSTRUCTIONS: Watch the pretty bubbles!
  11. Submit a zip file (with all source code) of your bubbles project to Canvas as explained in the section of this document: How to Submit.

Project Extra Credit

Adding the following are worth extra credit points:

  1. Add a 3 parameter constructor to the Bubble class with the following signature: (1 point)
     * Create a Bubble with the given size, initial direction and speed.
     * @param size Overall diameter of this bubble.
     * @param direction Initial direction in which this bubble moves.
     * @param speed Rate this bubble moves in pixels per act cycle.
    public Bubble(int size, int direction, int speed)

    The constructor must implement the specified parameters.

  2. After completing extra credit 1, add two more arrays to store the (x, y) coordinates, one named xName and the other named yName, for positioning bubbles arranged in the shape of your initials in the upper right quadrant of the world. Two letters of your initials is enough and the size of each letter must be at least 4 x 5 bubbles. Use a for-loop to read the coordinates for the position of each bubble and call the three-parameter constructor with a speed of 0. Pair programming on this extra credit is optional but requires both sets of initials. (2 points)

Make certain that your README.TXT file describes any extra credit attempted.

Grading Criteria

The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.

Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.

For information on grading policies, including interpretation of scores, see the syllabus page.

Project Compilation

  • 4: Source code compiles with no errors or warnings
  • 2: Source code compiles with warnings
  • 0: Does not compile, not turned in, or wrong folder name

Project Functionality

  • 10: Demonstrates mastery of the assignment
    • Has extra features or demonstrates techniques beyond the assignment
    • Applies concepts from the lesson(s) appropriately
    • Meets all specifications with particularly elegant solutions
    • No errors encountered during operation
  • 8: Has all the functionality expected of the assignment
    • Demonstrates many techniques from the lesson
    • Meets all specifications
    • Implementation seems more complicated than necessary.
    • May have one minor error
  • 6: Has most of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets all but one of the specifications
    • Implementation seems excessively complicated.
    • May have 2-3 minor errors
  • 4: Has some of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets at least 1/2 of the specifications
    • Implementation seems excessively complicated.
    • May have more than 3 minor errors
  • 2: Serious functional problems but shows some effort and understanding
    • Meets less than 1/2 of the of the specifications
    • Has a major error or many minor errors
    • Implementation seems very convoluted
    • Demonstrates few techniques from the lesson
  • 0: Does not execute, no specifications met, or wrong folder name
  • -2: penalty for not pair programming

README.TXT File for Project

  • 2: README.TXT file submitted with specified information included
  • 1: README.TXT submitted but some information was not included
  • 0: No README.TXT submitted or wrong folder name

Maximum Score: 16, plus extra credit

How to Submit

Submit means that you are presenting your work for consideration and grading. Follow these instructions carefully and exactly to turn in your quest (assignment) and maximize your XP:

  1. Create a folder named "project" (no extra characters) and place your complete programming project into this folder.
  2. Zip the folder and submit the zip file to the Q6 quest slot of Canvas.

Please do not add any extra characters to the above folder names. Also, do not put any spaces or special characters like #, : or $ in zip file or folder names. Your crafted code must work as submitted. Remember to test and double check your files before and after submitting them. If you make a mistake, you can resubmit up to the deadline but must resubmit all your quest files.

Home | Canvas | Schedule | Syllabus | Room Policies
Help | FAQ's | HowTo's | Links
Last Updated: April 04 2017 @00:46:29