2 回答

TA貢獻2051條經驗 獲得超10個贊
您想切換變量 ct
switch(ct) {
case CustomeType.retail:
/*Command*/
break;
case CustomerType.TRADE:
/*Command*/
break;
default:
/*else*/
}

TA貢獻1796條經驗 獲得超7個贊
試試這個:(很簡單)
public static double getDiscountPercent(CustomerType ct) {
double discountPercent = 0;
switch(ct) {
case CustomerType.RETAIL :
discountPercent = 0.156;
break;
case CustomerType.TRADE :
discountPercent = 0.30;
break;
case CustomerType.COLLEGE :
discountPercent = 0.20;
break;
default :
discountPercent = 0;
}
return discountPercent;
}
添加回答
舉報