Aolor:=‘green‘;
Bwriteln(green);
Cwriteln(color);
Da:=color=red;
第1题:
阅读以下说明和 Java 代码,填补代码中的空缺,将解答填入答题纸的对应栏内。 【说明】 设计 RGB 方式表示颜色的调色板,进行绘图。其类图如图 6-1 所示。该程序的 Java代码附后。图6-1 类图
【Java 代码】 //颜色类 class MyColor { private int red ,green, blue; public MyColor( ) { red = o; green = 0; blue = 0; } public MyColor(int red ,int green ,int blue) { this.red = red; this.green = green; this.blue = blue; } //其他方法略 public String toString( ) { return "Red: " + red + "\tGreen: " + green + "\tBlue " + blue; } } //调色板类 class Palette { public int number; / /颜色数 private (1)palette; //颜色表 public Palette( ) { number = 256; palette = new MyColor[number); } public Palette(MyColor[] palette ,int number) { (2)= number; (3)= palette; } //其他方法略 public String toString( ) { String str = ""; for (int i = 0; i < number; i++) { str +=i+ " : " + palette[i] + "\n"; } return str; } //绘图类 class Drawing { public (4) int COLORNUMBER = 16; public static void main(String[] args) { Palette palette; int red ,green ,blue; MyColor[] color = new MyColor[COLORNUMBER]; for (int i = 0; i < COLORNUMBER; i++) { red = (int) (Math.random( ) * 256); green = (int) (Math.random( ) * 256); blue = (int) (Math.random( ) * 256); color [i] = (5) (red ,green ,blue); } palette = new Palette(color ,COLORNUMBER); System.out.println(palette); } }
第2题:
第3题:
8、定义一个颜色的枚举类型Color,下面正确的是()。
A.public enum Color {red, green, yellow, blue}
B.public enum Color {1:red, 2:green, 3:yellow, 4:blue}
C.public enum Color {1:red; 2:green; 3:yellow; 4:blue}
D.public enum Color {Stringred, String green, String yellow, String blue}
第4题:
第5题:
定义一个颜色的枚举类型Color,下面正确的是()。
A.public enum Color {red, green, yellow, blue}
B.public enum Color {1:red, 2:green, 3:yellow, 4:blue}
C.public enum Color {1:red; 2:green; 3:yellow; 4:blue}
D.public enum Color {Stringred, String green, String yellow, String blue}