Assignment #10.

Added on - 16 Sep 2019

  • 2

    pages

  • 386

    words

  • 49

    views

  • 0

    downloads

Showing pages 1 to 1 of 2 pages
Assignment #10Two projects:Programming Project 6.22 and the following modification to the Splatprogram.Splat, RevisedStart with the "Splat" program from Ch. 4, Listings 4.7, 4.8, and 4.9. Create a Java projectwith 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 (whendrawn via itsdraw()) method. You can assume that the label is a very shortStringthat willfit in theCircle. Test that your program works by modifyingSplatPanelto give the circlesnames. (You can change the circles to be not filled-in and draw the text in white as in thenext figure.)Here's the fun part: modify theSplatPanelprogram so that instead of storing and creatingand drawing five arbitraryCircles, it generatesnrandomCirclesand stores them onanArrayList. Prompt the user via a dialog box for the number of circles. This entails a lot ofthings:Use of the dialog box to prompt for and retrieve the number of circles.Replacing the fiveCircleinstance variables with a singleArrayListinstancevariable.Writing a loop that generates the appropriate number of randomCircles.Be sure togenerate circles that fit on-screen!Use appropriate logic on the random number generationto 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 fivearbitraryCircles (which you've trashed), it iterates through the list ofCircles and printseach one.
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Unlock This Document