Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use java We will be removing the functionality of drawing Squares, Ellipses, Rectangles and Triangle (just comment those key events out) The application draws Circles

image text in transcribed

use javaimage text in transcribed

We will be removing the functionality of drawing Squares, Ellipses, Rectangles and Triangle (just comment those key events out) The application draws Circles when the C key is pressed . . For this application, as soon as the ball is drawn it should start moving o The Circles should bounce off the perimeter of the frame The Circles of different color should bounce off each other, and when they do they should swap colors The Circle of same Color will merge together by absorbing the smaller circle into the bigger circle. The size and the direction of the larger circle may not change o ShapeDriver will now need a Timer, and will also need to implement the ActionListener interface o Add the following to you ShapeDriver class: import javax.swing.Timer; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class ShapeDriver implements ActionListener private Timer timer public ShapeDriver) /l the second argument to the Timer Constructor takes an ActionListener /l the this key word informs the JVM to look inside this class for // the actionPerformed method that must be overridden when /l ActionListener is implemented /l Every tick of the clock will now run the actionPerformed method timer = new Timer(1000/bo, this); timer.start); /l Method that must be implemented since the class implements ActionListener public void actionPerformed(ActionEvent e) // move each circle // check if circle is in bounds, and bounce off the borders if need be Il check if circle hits another circle of different color, /l bounce circles off each other and swap colors We will be removing the functionality of drawing Squares, Ellipses, Rectangles and Triangle (just comment those key events out) The application draws Circles when the C key is pressed . . For this application, as soon as the ball is drawn it should start moving o The Circles should bounce off the perimeter of the frame The Circles of different color should bounce off each other, and when they do they should swap colors The Circle of same Color will merge together by absorbing the smaller circle into the bigger circle. The size and the direction of the larger circle may not change o ShapeDriver will now need a Timer, and will also need to implement the ActionListener interface o Add the following to you ShapeDriver class: import javax.swing.Timer; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class ShapeDriver implements ActionListener private Timer timer public ShapeDriver) /l the second argument to the Timer Constructor takes an ActionListener /l the this key word informs the JVM to look inside this class for // the actionPerformed method that must be overridden when /l ActionListener is implemented /l Every tick of the clock will now run the actionPerformed method timer = new Timer(1000/bo, this); timer.start); /l Method that must be implemented since the class implements ActionListener public void actionPerformed(ActionEvent e) // move each circle // check if circle is in bounds, and bounce off the borders if need be Il check if circle hits another circle of different color, /l bounce circles off each other and swap colors

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

How is Karen Slagles argument an example of confirmation bias?

Answered: 1 week ago