public enum Color {
Red, Orange, Yellow, Green, Cyan, Blue, Purple;
private boolean isRGB(Color color)
{
boolean b;
switch(color){
case Red:
System.out.println("Monday is a work day!!");
break;
case Orange:
System.out.println("Tusday is a work day!!");
case Yellow:
System.out.println("Wednesday is a work day!!");
case Green:
System.out.println("Thursday is a work day!!");
case Cyan:
System.out.println("Friday is a work day!!");
default: b = false;
System.out.println("Sorry this is not a working day!!\nn");
System.out.println("It's weekend!!!");
}
return(b);
}
这是我自己尝试的代码。 我在返回(b)中有一个错误,说'b'没有初始化....请帮助。
答案 0 :(得分:1)
替换
boolean b;
与
boolean b = true;
答案 1 :(得分:-2)
public enum Color{//......
- 老师添加了点,但没有要求添加。
public enum Color {
Red, Orange, Yellow, Green, Cyan, Blue, Purple;
}
private boolean isRGB(Color color) {
boolean b = false;
switch (color) {// i supposed to fill the blank switch( )
//And also i supposed write all the statements for switch, thats all was required me to do!!
case Red:
System.out.println("Monday is a work day!!");
break;
case Orange:
System.out.println("Tusday is a work day!!");
break;
case Yellow:
System.out.println("Wednesday is a work day!!");
break;
case Green:
System.out.println("Thursday is a work day!!");
break;
case Cyan:
System.out.println("Friday is a work day!!");
break;
default:
b = false;
System.out.println("Sorry this is not a working day!!\nn");
System.out.println("It's weekend!!!");
}
return (b);
}