The assignment is to modify the Splat program by adding a label to each Circle object and storing them in an ArrayList. The user should be prompted for the number of circles they want, and then the program will generate that many random circles with unique names and colors.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
Assignment #10 Two projects:Programming Project 6.22 and the following modification to the Splat program. Splat, Revised Start with the "Splat" program from Ch. 4, Listings 4.7, 4.8, and 4.9. Create a Java project with these three files, and run it to be sure it works. Modify the program so that eachCircleobject has a label that it stores and displays (when drawn via itsdraw()) method. You can assume that the label is a very shortStringthat will fit in theCircle. Test that your program works by modifyingSplatPanelto give the circles names. (You can change the circles to be not filled-in and draw the text in white as in the next figure.) Here's the fun part: modify theSplatPanelprogram so that instead of storing and creating and drawing five arbitraryCircles, it generatesnrandomCirclesand stores them on anArrayList. Prompt the user via a dialog box for the number of circles. This entails a lot of things: Use of the dialog box to prompt for and retrieve the number of circles. Replacing the fiveCircleinstance variables with a singleArrayListinstance variable. Writing a loop that generates the appropriate number of randomCircles.Be sure to generate circles that fit on-screen!Use appropriate logic on the random number generation to be sure. Use the index of the loop to "name" eachCircle. Generate random colors like this: Color color = new Color(generator.nextInt(0xffffff)); (wheregeneratoris yourRandomobject). Modify thepaintComponent()method so that instead of trying to print the five arbitraryCircles (which you've trashed), it iterates through the list ofCircles and prints each one.
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Now you should have an application that might produce something like the following picture. In this case, the user asked for 9 circles, which the program labeled 0 through 8. At this point, you have completed this project. It will be extended in the final homework!