Step-by-step explanation:
I've written a basic Circle class and a Main class for testing it.
You will have to initialize the x and y yourself, since I don't know how big your screen is. It's just center of screen x/y - radius of circle. There is 2 constructor, one for color(r,g,b) and another for color(Color).
Review and test the code for yourself.
Rate 5 star, if this helped :)
Answer:
import java.util.*;
import java.awt.Color;//Must import Color class in Circle class
public class Main {
public static void main(String[] args) {
System.out.println("Creating circle: ");
Circle c1 = new Circle(9,8,7, 100, 100,0);//rgb value
c1.printCircle();
Circle c2 = new Circle(1,2,3, Color.red);//color value
c2.printCircle();
}
}
public class Circle{
private int x, y, radius;
private Color color;
//Constructor
//parameter: x, y, radius, color in RGB VALUE
public Circle(int x, int y, int radius, int r, int g, int b){
this.x=x;
this.y=y;
this.radius=radius;
color = new Color(r,g,b);
}
//Overloaded Constructor for color in strong VALUE
public Circle(int x, int y, int radius, Color color){
this.x=x;
this.y=y;
this.radius=radius;
this.color = color;
}
//Test function. can delete after testing
//Prints the x,y,radius, and color of circle
public void printCircle(){
System.out.printf("Circle: x:%d y:%d radius:%d color:%s\\",x, y, radius, color.toString());
}
}