我试图从一种颜色变为红色,从另一种颜色变为绿色,从另一种颜色变为蓝色并添加它们以制作全新的颜色。但它一直说不能找到第2行符号,现在它说我需要一个返回类型。我该怎么办?
public static four (String[] args) {
Color colour4 = new Color();
int red = colour1.getRed();
int green = colour2.getGreen();
int blue = colour3.getBlue();
System.out.println("The RGB is: ("+red+","+green+","+blue+")");
}
其他颜色的代码通常是这个
public static void second (String[] args) {
Scanner b = new Scanner (System.in);
System.out.println("What's the decimal?");
int value = b.nextInt();
System.out.println("Your decimal is"+value);
Color colour2 = new Color(value);
int red = colour2.getRed();
int green = colour2.getGreen();
int blue = colour2.getBlue();
System.out.println("The RGB is: ("+red+","+green+","+blue+")");
}
答案 0 :(得分:0)
您的代码完全错误:
main
,并且应为void
(您未指定返回类型)。colour1
。可能的解决方案:
public static void main (String[] args) {
Scanner b = new Scanner (System.in);
System.out.println("What's the first color decimal?");
int value = b.nextInt();
Color colour1 = new Color(value);
System.out.println("What's the second color decimal?");
value = b.nextInt();
Color colour2 = new Color(value);
System.out.println("What's the third color decimal?");
value = b.nextInt();
Color colour3 = new Color(value);
int red = colour1.getRed();
int green = colour2.getGreen();
int blue = colour3.getBlue();
Color colour4 = new Color(red,green,blue);
//do something with colour4
System.out.println("The RGB is: ("+red+","+green+","+blue+")");
}