Hi beginner programer here I need help with printing the results for this program. I have already created a method to compare the circles radius, however I would like to include the color of the circles compared when I print the results, I however cant seem to be able to do that as shown by the (?). how can i print a different color?
ex: when i compare green and red "The green circle is bigger than the red circle" to when i compare green to blue "The green circle is smaller than the blue circle"
//class
// main method
//asked for input and stored values in variable for r1, x1, y1
g.setColor(Color.GREEN);
g.fillOval(x1-r1, y1-r1, r1*2, r1*2);
//asked for input and stored values in variable for r2, x2, y2
g.setColor(Color.RED);
g.fillOval(x2-r2, y2-r2, r2*2, r2*2);
//asked for input and stored values in variable for r3, x3, y3
g.setColor(Color.BLUE);
g.fillOval(x3-r3, y3-r3, r3*2, r3*2);
int compare = size(r1, r2);
result1(compare);
compare = size(r1, r3);
result1(compare);
compare = size(r2, r3);
result1(compare);
public static int size(int r1, int r2){
if(r1 < r2){
return -1;
}else if( r1 == r2){
return 0;
}else{
return 1;
}
}
public static void result1(int n){
if (n == -1){
System.out.println("The " + ? + "cirlce is smaller than the " + ? + "circle.");
}else if(n == 0){
System.out.println("The " + ? + "circle is the same size as the " + ? + "cirle.");
}else{
System.out.println("The " + ? + "circle is bigger than the " + ? + "circle");
}
Thanks for the help.
Aucun commentaire:
Enregistrer un commentaire