Question
1) Using the Bubbles scenario (see page 120) that is contained in your downloaded book-scenarios, save a copy of the scenario in a folder called
1) Using the Bubbles scenario (see page 120) that is contained in your downloaded book-scenarios, save a copy of the scenario in a folder called assign6B on your desktop. This folder will contain all the files required for the game and the files necessary for you to complete this assignment. By performing this, you will not have to modify your original files. This assignment shall practice the most fundamental construct for looping, the while loop. 2) Implement the following requirements: A. Open the bubble scenario. You will see that the world is empty. In the world subclass Space, create a new private method called setup(). Call this method from the constructor. In this method, create a new bubble and place it in the center of the world. B. Using a while construct, modify the setup() method to additionally place bubbles on a diagonal line. The first bubble shall be placed at 0,0, and each additional bubble shall be added so that they go from the top left corner of the world to the bottom right corner of the world. The last bubble shall be at 900,600 (for 21 bubbles in total). Use your loop counter variable to achieve computation of bubble placement. Please note there are two bubbles in the center of the display. C. Add another while loop to the setup() method that places some more bubbles. This loop shall place 10 bubbles, in a horizontal line, starting at x=300, y=100, with x increasing by 40 every time and y being constant. (That is, the bubbles are at 300, 100, then 340, 100, then 380, 100, and so on.) The size of the bubble shall also increase, starting with 10 for the first bubble, then 20, then 30, etc. Use the second Bubble constructor for this (the one with one parameter). Use your loop counter variable to achieve computation of bubble size and placement. 3. Document your new code. 4. Compile and test your new code to make sure the Bubbles scenario works properly.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started