public class useCup{
public static void main(String[] args){
Cup cup = new Cup();
Cup cup2 = new Cup(2.5f, 2, 1);
}
public class Cup {
float volume;
int shape;
int colour;
public Cup(){
System.out.println("水杯可以用来装液体");
}
public Cup(float volume,int shape,int colour){
volume = volume;
if(0<volume||volume<=1.0){
System.out.println("说明此杯为小型水杯!");
}else if(1.0<volume||volume<=3.0){
System.out.println("说明此杯为中型水杯!");
}else if(3.0<volume||volume<=5.0){
System.out.println("说明此杯为大型水杯!");
}else{
System.out.println("输入体积超出正常数值,请从新输入!");
}
switch (shape){
case 1:
System.out.println("杯型为圆柱型!");
break;
case 2:
System.out.println("杯型为圆台型!");
break;
default:
System.out.println("输入错误,请从新输入!");
}
shape = shape;
switch (colour){
case 1:
System.out.println("水杯颜色为黄色!");
break;
case 2:
System.out.println("水杯颜色为绿色!");
break;
case 3:
System.out.println("水杯颜色为淡紫色!");
break;
default:
System.out.println("没有该颜色类型的水杯,请从新选择颜色!");
}
colour = colour;
System.out.println("水杯可以有体积,形状,颜色进行区分");
}
}
}
问:为什么我的水杯volume 属性不管赋何值,结果都是“说明此杯为小型水杯!”呢?
求大神指教,最好讲的详细些,谢谢!
慕老板
saber大爱_0
慕的地6079101
相关分类