基本弄完,感觉输入序号1,2一起查询的,应该是拆分字符或者把1 2提取出来转换成数字吧,没弄这个。
else if((OPERATION_MAIN.equals(in.toUpperCase()))
|| OPERATION_MAIN.substring(0, 1).equals(in.toUpperCase())){
prenious =null;
step=1;
System.out.println(CONTEXT);
} else if ((OPERATION_BREAK.equals(in.toUpperCase()))
|| OPERATION_BREAK.substring(0, 1).equals(in.toUpperCase())) {
prenious =null;
step=1;
System.out.println("退出当前功能,返回主菜单");
System.out.println(CONTEXT);
} else if ((OPERATION_UPDATE.equals(in.toUpperCase()))
|| OPERATION_UPDATE.substring(0, 1).equals(in.toUpperCase())
|| OPERATION_UPDATE.equals(prenious)) {
prenious = OPERATION_UPDATE;
if (step == 1) {
System.out.println("请输入您要更新的女神编号:");
} else if (step == 2) {
x = Integer.parseInt(in);
goddess.setId(x);
try {
Goddess goddess2 = new Goddess();
goddess2 = action.get(x);
goddess.setUser_name(goddess2.getUser_name());
goddess.setAge(goddess2.getAge());
goddess.setBirthday(goddess2.getBirthday());
goddess.setEmail(goddess2.getEmail());
goddess.setMobile(goddess2.getMobile());
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("请输入更新后女神的姓名(不变则输入null即可):");
} else if (step == 3) {
if (!(in.equals("null"))) {
{
goddess.setUser_name(in);
System.out.println("请输入更新后女神的年龄(不变则输入null即可):");
}
}
}else if (step == 4) {
if (!(in.equals("null"))) {
int y = Integer.valueOf(in);
goddess.setAge(y);
System.out.println("请输入更新后的女神生日(不变则输入null即可):");
}else{
System.out.println("请输入更新后的女神生日(不变则输入null即可):");
}
} else if (step == 5) {
if (!(in.equals("null"))) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
java.util.Date birthday = null;
try {
birthday = sdf.parse(in);
goddess.setBirthday(birthday);
System.out.println("请输入更新后女神的邮箱(不变则输入null即可):");
} catch (ParseException e) {
e.printStackTrace();
}
}else{
System.out.println("请输入更新后女神的邮箱(不变则输入null即可):");
}
} else if (step == 6) {
if (!(in.equals("null"))) {
goddess.setEmail(in);
System.out.println("请输入更新后女神电话(不变则输入null即可):");
}else{
System.out.println("请输入更新后女神电话(不变则输入null即可):");
}
} else if (step == 7) {
if (!(in.equals("null"))) {
goddess.setMobile(in);
try {
action.edit(goddess);
System.out.println("女神信息更新成功");
prenious =null;
step=1;
} catch (Exception e) {
e.printStackTrace();
System.out.println("女神信息更新失败");
}
}else{
try {
action.edit(goddess);
System.out.println("女神信息更新成功");
prenious =null;
step=1;
} catch (Exception e) {
e.printStackTrace();
System.out.println("女神信息更新失败");
}
}
}
if (OPERATION_UPDATE.equals(prenious)) {
step++;
}
} else if ((OPERATION_SEARCH.equals(in.toUpperCase()))
|| OPERATION_SEARCH.substring(0, 1).equals(in.toUpperCase())
|| OPERATION_SEARCH.equals(prenious)) {
prenious = OPERATION_SEARCH;
if (step == 1) {
System.out.println("请输入您要查询的女神姓名:");
} else if (step == 2) {
name = in;
System.out.println("请输入您要查询的女神手机:");
} else if (step == 3) {
String mobile = in;
try {
List<Goddess> result = action.search(name, mobile);
for (Goddess a : result) {
System.out.println(a.toString());
}
prenious =null;
step=1;
} catch (Exception e) {
e.printStackTrace();
}
}
if (OPERATION_SEARCH.equals(prenious)) {
step++;
}
}