亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

不了解記憶功能

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;
?? 是什么意思?記憶功能是怎么用的?

正在回答

1 回答

在使用增加功能時,將OPERATION_ADD的值賦給prenious;說明了將值付給prenious時就是調用了增加的功能,所以進行step++。 ? 反之如果不使用增加功能,就不會將OPERATION_ADD的值賦給prenious,所以不會增加進行賦值

1 回復 有任何疑惑可以回復我~
#1

moummm 提問者

非常感謝!
2017-08-27 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

不了解記憶功能

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號