+1(978)310-4246 credencewriters@gmail.com


I have a java coding lab where there are missing coding in the text and I have to find them and fix them. That’s all there is to it.

import javax.swing.JFrame;
public class Main { private static final int FRAME_WIDTH = 600; private
static final int FRAME_HEIGHT = 350;
public static void main(String[] args)
// Instantiate and define JFrame
JFrame frame = new JFrame();
frame.setLocation(5, 5);
frame.setTitle(“Non-Intersecting Circles Lab”);
// Draw circles
CirclesComponent component = new CirclesComponent();
APCSA Unit 8 Array Lists Lab – Non-Intersecting Circles
SUBMIT in Repl.it!
Problem Description:
The CirclesComponent class has a list of non-intersecting circles being drawn. For this lab, two circles are to be
considered intersecting if any part of one circle lies within another. This list of non-intersecting circles is stored in an
ArrayList of Ellipse2D.Double objects instantiated by the constructor. The paintComponent method is
automatically called when the component is added to a frame or whenever the frame needs to be repainted. This
method calls upon generateCircles to generate randomly located and sized circles until 1000 non-intersecting
circles have been added to the list, and calls upon drawCircles to draw the circles. Click here for a demo video.
The main class, CirclesLab, has been provided for you and the CirclesComponent class has been started for
you. Remember, no magic numbers! All constants must be class (static) constants.
85-point Version – Implement the following in the CirclesComponent Class
● Declare an ArrayList of Ellipse2D.Double instance variable to hold your circles.
● Constructor – instantiate your ArrayList of Ellipse2D.Double objects.
● generateCircles – Empty the ArrayList of any existing circles (re-instantiating will do this or call its clear
method) and add 1000 intersecting, randomly located and sized circles to the list. Your circles must not overlap the edges.
Generate an Ellipse2D.Double object with:
Random diameter in the floating-point range [1.0, 61.0)
Random x coordinate in the range [0, component’s width – diameter)
Random y coordinate in the range [0, component’s height – diameter)
â—‹ Remember, getWidth() and getHeight() return the width and height of the component.
● drawCircles – for each circle in the list, generate a random color and draw the circle. Remember, there are two
different Color constructors. One takes 3 random floats in the range [0.0, 1.0), and the other takes 3 random integers
each in the range [0, 255].
85-point Version Sample Output
100-point Version – Implement the following in the CirclesComponent Class
● generateCircles – Only add the newly generated circle to the list if it does not intersect with any other circles in
the list.
● circleIntersects – returns true if the given circle intersects with one or more circles in the list; false
otherwise. Check the given circle against the circles in the list. Two circles intersect if the distance between their two
centers is less than the sum of their radii. You will need to use the distance formula:
𝑑 = √(𝑥2 − 𝑥1)2 + (𝑦2 − 𝑦1)2
where (x1, y1) is the center of the given circle, and (x2, y2) is the center of another circle. The following methods access
information of an Ellipse2D.Double object: getWidth(), getHeight(), getCenterX(), and
Finished early and bored? Investigate drawing solid semi-transparent circles using the 4-parameter Color constructor
that adds an alpha component.
100-point Version Sample Output
100-point Version Sample Output with Optional Solid Semi-Transparent Circles
import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D; import javax.swing.JComponent; import
java.util.List; import java.util.ArrayList;
public class CirclesComponent extends JComponent {
public CirclesComponent()
* Generate and draw all of the circles
* @param g the graphics object for drawing
public void paintComponent(Graphics g)
Graphics2D g2 = (Graphics2D) g;
private void generateCircles()
private void drawCircles(Graphics2D g2)
// 100-point Version
private boolean circleIntersects(Ellipse2D.Double circle)
return true;

Purchase answer to see full

error: Content is protected !!