读书人

哪位高手能帮小弟我测试一上java ee。

发布时间: 2012-10-12 10:17:04 作者: rapoo

谁能帮我测试一下java ee。出错时我按钮继续运行,不再提示,结果现在有错误也不提示了。
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package homework;

/**
*
* @author Administrator
*/
/*
* To change this template, choose Tools | Templates and open the template in
* the editor.
*/
import java.util.Scanner;

/**
*
* @author Administrator
*/
public class Fan {

int SLOW = 1, MEDIUM = 2, FASE = 3;
private int speed = SLOW;
private boolean on = false;
private double radius = 5;
private String color = "blue";

public Fan() {
}

public void setspeed(int s) {
this.speed = s;
}

public void setstate(boolean a) {
this.on = a;
}

public void setradius(double r) {
this.radius = r;
}

public void setcolor(String b) {
this.color = b;
}

public int getspeed() {
return speed;
}

public boolean getstate() {
return on;
}

public double getradius() {
return radius;
}

public void toString(boolean on) {
if (on == true) {
System.out.println("Fan打开了; " + "Fan的半径: " + radius + "\n" + "速度:" + speed + "\n" + "颜色: " + color + "\n");

} else if (on == false) {
System.out.println("Fan被关闭了");
}
}

public void choose1() {
Scanner input = new Scanner(System.in);
System.out.println("1.状态 2.风速 3.半径 4.颜色 5.退出");
int j = input.nextInt();
while (j != 5) {
if (j != 1 && j != 2 && j != 3 && j != 4) {
System.out.println("输入有误,请重新输入!!!");
} else if (j == 1) {
System.out.println("1.关闭风扇 2.打开风扇");
int k = input.nextInt();
if (k == 1) {
setstate(false);
} else {
setstate(true);
}
break;
} else if (j == 2) {
System.out.println("1.slow 2.middle 3.fast");
int k = input.nextInt();
if (k == 1) {
setspeed(1);
} else if (k == 2) {
setspeed(2);
} else {
setspeed(3);
}
break;
} else if (j == 3) {
System.out.println("输入半径");
int k = input.nextInt();
setradius(k);
break;
} else if (j == 4) {
System.out.println("输入颜色");
String m = input.toString();
setcolor(m);
break;
}
}
}

public void choose2() {
boolean jan = getstate();
toString(jan);
}

public static void main(String args[]) {
Fan application = new Fan();


int i;
System.out.println("------------------------");
System.out.println("1.更改Fan的属性 2.查看Fan的属性 3.退出");
System.out.println("------------------------");
Scanner input = new Scanner(System.in);
i = input.nextInt();
while (i != 3) {
if (i != 1 && i != 2) {
System.out.println("输入有误!");
} else if (i == 1) {
application.choose1();
} else if (i == 2) {
application.choose2();
}
System.out.println("------------------------");
System.out.println("1.更改Fan的属性 2.查看Fan的属性 3.退出");
System.out.println("------------------------");
System.out.println("再次选择");
i = input.nextInt();
}
System.out.println("感谢使用!");
}
}


[解决办法]
是不是因为变量用了专有词汇?

读书人网 >J2EE开发

热点推荐