Use JAVA to create A Ball Bouncing Application using the attached diagram. It is JAVA code using
Fantastic news! We've Found the answer you've been seeking!
Question:
Use JAVA to create A Ball Bouncing Application using the attached diagram. It is JAVA code using Swing.
PLEASE ONLY USE the class names and method names in the diagram to make the application.
Class BouncingBallApp
Class BouncingBallPanel
Class Ball
Transcribed Image Text:
JFrame Bouncing Ball Application (26.9) Class Diagram JPanel +setSize(in width: int, in height: int): void +setVisible(in visible: bool) +setDefaultClosingOperation(in operation: int): void I +paintComponent(): void MouseListener Runnable BouncingBallPanel BouncingBallApp ballCount: int 1 1 +run(): void +main(): void +mouseClicked(): void +mouseEntered(): void Ball x: double y: double diameter: double color 1 20 +mouseExited(): void +mousePressed(): void +mouseReleased(): void deltaX: int deltaY: int +move(): void BouncingBallApp High level Description: The application creates a maximum of 20 balls of random color and displays the balls moving within a window. The rate of movement can be controlled by modifying the delay time in the run() method. main(): 1. Create BouncingBallApp instance 2. Set the appropriate Window Closing features (i.e., close Window when "X" is clicked) 3. Create a "Bouncing BallPanel" (BBP) instance and add to container 4. Make the BBP the "MouseListener" object (i.e., handle Mouse Click event) 5. Set Window size 6. Make Window Visible Note: MouseListener and Runnable are interfaces BouncingBallPanel constructor() Create an empty array for 20 "Ball" objects. The "Ball" array accessible via an instance variable (because "paintComponent" and "MouseClicked" must be able to access). run() loop forever loop for each ball move() end loop repaint() delay(1sec) // once working may want to play with this for speed end loop mouseClicked(...) Create a new Ball and add to the array (x, y should be random, and Color) Increment ballCount If ballCount = 1 Start the Thread // must use the "BouncingBallPanel object created in main() paintComponent(...) loop for each ball Draw all balls in the array end loop JFrame Bouncing Ball Application (26.9) Class Diagram JPanel +setSize(in width: int, in height: int): void +setVisible(in visible: bool) +setDefaultClosingOperation(in operation: int): void I +paintComponent(): void MouseListener Runnable BouncingBallPanel BouncingBallApp ballCount: int 1 1 +run(): void +main(): void +mouseClicked(): void +mouseEntered(): void Ball x: double y: double diameter: double color 1 20 +mouseExited(): void +mousePressed(): void +mouseReleased(): void deltaX: int deltaY: int +move(): void BouncingBallApp High level Description: The application creates a maximum of 20 balls of random color and displays the balls moving within a window. The rate of movement can be controlled by modifying the delay time in the run() method. main(): 1. Create BouncingBallApp instance 2. Set the appropriate Window Closing features (i.e., close Window when "X" is clicked) 3. Create a "Bouncing BallPanel" (BBP) instance and add to container 4. Make the BBP the "MouseListener" object (i.e., handle Mouse Click event) 5. Set Window size 6. Make Window Visible Note: MouseListener and Runnable are interfaces BouncingBallPanel constructor() Create an empty array for 20 "Ball" objects. The "Ball" array accessible via an instance variable (because "paintComponent" and "MouseClicked" must be able to access). run() loop forever loop for each ball move() end loop repaint() delay(1sec) // once working may want to play with this for speed end loop mouseClicked(...) Create a new Ball and add to the array (x, y should be random, and Color) Increment ballCount If ballCount = 1 Start the Thread // must use the "BouncingBallPanel object created in main() paintComponent(...) loop for each ball Draw all balls in the array end loop
Expert Answer:
Answer rating: 100% (QA)
Based on the provided class diagram and instructions heres a Java program implementing the described Ball Bouncing Application using Swing java import ... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
a. Find the probability of getting exactly 1 girl in 10 births. b. Find the probability of getting 1 or fewer girls in 10 births. c. Which probability is relevant for determining whether 1 is an...
-
A skier moves down a 12 slope at constant speed. What can you say about the coefficient of friction, k? Assume the speed is low enough that air resistance can be ignored.
-
What is pervaporation?
-
Although the customer loyalty project at Petrie Electronics had gone slowly at first, the past few weeks had been fast-paced and busy, Jim Watanabe, the project manager, thought to himself. He had...
-
The Ortega Food Company needs to ship 100 cases of hot tamales from its warehouse in San Diego to a distributor in New York City at minimum cost. The costs associated with shipping 100 cases between...
-
2. 2. A 20 kg child climbs to the top of a slide that is 3 m above the ground level. She starts from rest and slides down the incline. a. Define and model the energy of the system with Energy Bar...
-
In early 2016, Doc and Lyn McGee formed the McGee Cake Company. The company produced a full line of cakes, and its specialties included chess cake,* lemon pound cake, and double-iced, double...
-
Assume that mining operations are regulated by legislation that provide as follows: 1 Mining operations to be under lease or licence. No mining lease, quarry license, short-term permit or any other...
-
Microsoft Project is a Microsoft proprietary software application developed for project management. Using the Internet resources describe this software application. What are its features and...
-
For a manager engaging in equity market-neutral pairs trading, how are longs and shorts matched?
-
A risk-averse investor's goal is to create a portfolio that maximizes return for a given level of risk. Question 7 options: True False
-
Write a Java program that uses the ForkJoinPool to perform a parallel merge sort algorithm.
-
Solve rational equations x^(7)C Solve for s. (s-4)/(s+2)=(s+6)/(s+7)
-
Exercise (1): Molina Company had a $700 credit balance in Allowance for Doubtful Accounts at December 31, 2016, before the current year's provision for uncollectible accounts. An aging of the...
-
Reconsider Prob. 1474. In order to drain the tank faster, a pump is installed near the tank exit as in Fig. P1475. Determine how much pump power input is necessary to establish an average water...
-
Write a class ContactInfo to store contact information for a person. It should have attributes for a persons name, business phone, home phone, cell phone, e-mail address, and home address. It should...
-
Write a program that will record the votes for one of two candidates by using the class VoteRecorder, which you will design and create. Vote Recorder will have static variables to keep track of the...
-
Create a GUI application that draws the following picture of a magic wand, using polygons and polylines:
-
Redo the preceding exercise, this time using the mathematics scores. Preceding Exercise Use the reading comprehension data in Exercise 6.18 to test the null hypothesis that the population mean of X...
-
What type of accounts are accounts receivable and inventory? (a) Cash accounts. (b) Operating accounts. (c) Financing accounts. (d) Investing accounts.
-
Which of the following is a cash outflow? (a) Proceeds from borrowing. (b) Repayments of debt principal. (c) Payment for taxes. (d) Both (b) and (c).
Study smarter with the SolutionInn App