Привет, начинающий программист, мне нужна помощь в печати результатов для этой программы. Я уже создал метод для сравнения радиуса кругов, однако я хотел бы включить цвет сравниваемых кругов при печати результатов, однако я не могу сделать это, как показано (?). как я могу напечатать другой цвет?
пример: когда я сравниваю зеленый и красный «Зеленый круг больше красного круга» и когда я сравниваю зеленый и синий «Зеленый круг меньше синего круга»
//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");
}
Спасибо за помощь.