switch ステートメントを実行するために数字を生成しようとしていますが、適切な結果が生成されません。ただし、IF ブロックを削除すると、正しく機能します。コードの問題は何ですか?
import static java.lang.Character.isDigit;
public class TrySwitch
{
enum WashChoise {Cotton, Wool, Linen, Synthetic }
public static void main(String[]args)
{
WashChoise Wash = WashChoise.Cotton;
int Clothes = 1;
Clothes = (int) (128.0 * Math.random());
if(isDigit(Clothes))
{
switch (Clothes)
{
case 1:
System.out.println("Washing Shirt");
Wash = WashChoise.Cotton;
break;
case 2:
System.out.println("Washing Sweaters");
Wash = WashChoise.Wool;
break;
case 3:
System.out.println("Socks ");
Wash = WashChoise.Linen;
break;
case 4:
System.out.println("washing Paints");
Wash = WashChoise.Synthetic;
break;
}
switch(Wash)
{
case Wool:
System.out.println("Temprature is 120' C "+Clothes);
break;
case Cotton:
System.out.println("Temprature is 170' C "+Clothes);
break;
case Synthetic:
System.out.println("Temprature is 130' C "+Clothes);
break;
case Linen:
System.out.println("Temprature is 180' C "+Clothes);
break;
}
}
else{
System.out.println("Upps! we don't have a digit, we have :"+Clothes );
}
}
}