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
-
Overhead Photography has applied for property and liability insurance. Overhead provides drone inspection services for insurers, architectural firms, and other entities that want to obtain...
-
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...
-
Accident data were analyzed to determine the numbers of fatal accidents for automobiles of three sizes. The data for 346 accidents are as follows: Do the data indicate that the frequency of fatal...
-
Explain the difference between full-absorption costing and direct costing. How does absorption costing help a manufacturer determine a reasonable price?
-
When Fleetwood Enterprises, Inc., a large producer of recreational vehicles and manufactured housing, warned that it might not be able to generate enough cash to satisfy debt requirements and could...
-
1. Identify and describe the major ethical issues facing Wal-Mart and the stakeholders likely to be affected. 2. Wal-Mart has been said to have excessive power in its relationship with communities....
-
Suppose that Lebanon has placed tariffs on its imports and exports. The import tariff is 13%, and the export tariff is 8%. If Lebanon has a balance of trade of (equivalent US dollars) $5,510,000 and...
-
Rob is selling his house in Tucson. Jim, his agent, has found a buyer, Sid. Sid signs a contract in which he agrees to buy the house for $250,000 but the document provides that "this sale is...
-
Consider the following information: State of Probability of State of Rate of Return if State Occurs Economy Economy Stock A Stock B Stock C Boom 0.30 0.23 0.31 0.30 Good 0.15 0.16 0.11 0.12 Poor 0.30...
-
2. Consider a data stream consisting of 1000 bytes. You want to transmit this data stream over a communication channel using CRC-32 with the polynomial x^32 + x^26 + x^23 + x^22 + x^16+x^12+x^11 +...
-
Direct Materials, January 2008 $40,000 Work in Process, December 2008 $69,000 Direct Labor $48,500 Finished Goods December 105,000 Finished Goods January 128,000 Manufacturing Overhead 72,500 Direct...
-
Q1What are two things you need to know about a 'glass cleaner' (for cleaning drinking glasses) in order to use it effectively in a commercial kitchen? Q2. Why would staff use a 'pesticide' when...
-
Task: You will select a specific equity-oriented career based on the research you completed previously using the two resource banks. You will then completed a report that demonstrates that you...
-
The following data are for four independent process-costing departments. Inputs are added continuously. A B C D Beginning inventory 6,000 3,000 44,000 Percent completion 40% 80% 70% Units started...
-
Procter & Gamble Co. manufactures laundry detergent and incurred the following costs for the production of 22,000 units: Actual direct materials cost: $55,000 Standard direct materials cost: $44,000...
-
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:
-
Define various cost equations (Learning Objective 2) Write the cost equation for each of the following cost behaviors. Define the variables in each equation. a. Fixed b. Mixed c. Variable
-
Predict total mixed costs (Learning Objective 2) Ritter Razors produces deluxe razors that compete with Gillette's Mach line of razors. Total manufacturing costs are \(\$ 100,000\) when 20,000...
-
Prepare and analyze a scatter plot (Learning Objective 3) Lube-for-Less is a car care center specializing in ten-minute oil changes. Lube-for-Less has two service bays, which limits its capacity to...
Study smarter with the SolutionInn App