不了解记忆功能
public class view { private static final String CONTEXT="欢迎来到女神禁区:\n" + "下面是女神禁区的功能列表:\n" + "[MAIN/M]:主菜单\n" + "[QUERY/Q]:查看全部女神的信息\n" + "[GET/G]:查看某位女神的详细信息\n" + "[ADD/A]:添加女神信息\n" + "[UPDATE/U]:更新女神信息\n" + "[DELETE/D]:删除女神信息\n" + "[SEARCH/S]:查询女神信息(根据姓名、手机号来查询)\n" + "[EXIT/E]:退出女神禁区\n" + "[BREAK/B]:退出当前功能,返回主菜单"; private static final String OPERATION_MAIN="MAIN"; private static final String OPERATION_QUERY="QUERY"; private static final String OPERATION_GET="GET"; private static final String OPERATION_ADD="ADD"; private static final String OPERATION_UPDATE="UPDATE"; private static final String OPERATION_DELETE="DELETE"; private static final String OPERATION_SEARCH="SEARCH"; private static final String OPERATION_EXIT="EXIT"; private static final String OPERATION_BREAK="BREAK"; public static void main(String[] args) throws Exception { System.out.println(CONTEXT); Scanner scan = new Scanner(System.in); Goddess g = new Goddess(); ActionGoddess ag = new ActionGoddess(); String prenious = null; int step = 1; while(scan.hasNext()){ String in=scan.next().toString(); if(OPERATION_EXIT.equals(in.toUpperCase()) //退出 ||OPERATION_EXIT.substring(0, 1).equals(in.toUpperCase())){ System.out.println("您已成功退出女神禁区。"); break; }else if(OPERATION_DELETE.equals(in.toUpperCase()) //删除女神 ||OPERATION_DELETE.substring(0, 1).equals(in.toUpperCase())) { }else if(OPERATION_QUERY.equals(in.toUpperCase()) //查询全部女神信息 ||OPERATION_QUERY.substring(0, 1).equals(in.toUpperCase())){ List<Goddess> goddesses = ag.query(); for (int i=0;i<goddesses.size();i++) System.out.println(goddesses.get(i).toString()); }else if(OPERATION_ADD.equals(in.toUpperCase()) //增加女神 ||OPERATION_ADD.substring(0, 1).equals(in.toUpperCase()) ||OPERATION_ADD.equals(prenious)){ prenious = OPERATION_ADD; if(step == 1){ System.out.println("请输入女神的姓名:"); }else if(step == 2){ g.setUser_name(in); System.out.println("请输入女神的年龄:"); }else if(step == 3){ g.setAge(Integer.valueOf(in)); System.out.println("请输入女神的生日:(例如:yyyy-MM-dd)"); }else if(step==4){ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { Date data = sdf.parse(in); g.setBirthday(data); System.out.println("请输入女神的邮箱:"); } catch (ParseException e) { e.printStackTrace(); step = 3; } }else if(step == 5){ g.setEmail(in); System.out.println("请输入女神的电话号码:"); }else if (step==6){ g.setMobile(in); try { ag.addGoddess(g); System.out.println("新增女神成功"); } catch (Exception e) { e.printStackTrace(); System.out.println("新增女神失败"); } } if (prenious.equals(OPERATION_ADD)) step++; } } } }
OPERATION_ADD.equals(prenious) 和 prenious = OPERATION_ADD;
是什么意思?记忆功能是怎么用的?