Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a Circle class that is inherited from a Shape class. How can I make a met

ID: 3645936 • Letter: I

Question

I have a Circle class that is inherited from a Shape class. How can I make a method in the RandomShapes class to paint the shapes???




import java.awt.*;
public class RandomShapes {

public void randomArray()
{
//Paint Circle
}
}




public class Shape
{
protected int x, y, size;


protected Shape()
{
randomize();
}

protected void randomize()
{
x = (int) (200 * Math.random()) + Abutton.BUTTON_WIDTH * 2;
y = (int) (200 * Math.random()) + Abutton.BUTTON_HEIGHT * 2;
size = (int) (100*Math.random());
}

public void paint(Graphics pane)
{

}
}



public class Circle extends Shape
{
public void paint(Graphics pane)
{
pane.setColor(Color.cyan);
pane.fillOval(x, y, size, size);
pane.setColor(Color.black);
pane.drawOval(x, y, size, size);
}
}

Explanation / Answer

public DrawingColor(){ JFrame frame = new JFrame("Drawing with Alpha"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new MyComponent()); frame.setSize(400,400); frame.setVisible(true); }