この記事では、参照のためにショッピング管理システムのJava実装の特定のコードを共有しています。特定のコンテンツは次のとおりです
キーコンテンツ
Javaブランチ構造エクササイズダイナミックアレイレジストリの読み取り、書き込み、削除
コード:
パッケージEndless; Import java.util.arraylist; Import Java.util.random;/*** @java01.person1.java* @author現在java.util.scanner; Import java.util.prefs.backingstoreException; Import java.util.prefs.preferences; public class persion {static int s;静的ブールHuiyuan、Xhuiyuan;静的文字列bke = "Pepsi Cola"、Ke = "500ml Cola Bottle"、M = "5 kgの小麦粉"、ss = "1 supor炒め鍋"、o = "l'orealトナーボトル"; Static ArrayList <String> array = new ArrayList <String>();静的設定goodsnodes = preferences.systemroot()。node( "goods"); // Node Static Preferences GoodsChildNode = GoodsNodes.Node( "Goods"); //子ノードの作成public static void main(string [] args){outline(); System.out.println( "/Twelcomeショッピング管理システムを使用する"); System.out.println( "/t1.login System/n/t2.exit program/n");概要(); int n = scanint(); if(n == 1){login(); } else if(n == 2){system.out.println( "exited"); System.Exit(0); } else {system.out.println( "再選択してください:");メイン(null); } } public static void outline(){ System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /n"); } public static int scanint(){int x = 0; try {scanner scan = new Scanner(system.in); x = scan.nextint(); } catch(Exception e){System.out.println( "入力が間違っている場合、番号を入力してください:"); } xを返します。 } public static string scanstr(){string x = null; try {scanner scan = new Scanner(system.in); x = scan.next(); } catch(Exception e){System.out.println( "入力が間違っている場合、文字列:"); } xを返します。 } public static void login(){system.out.println( " * * * * * * * * * * * * * * * * * * * * * * * * * /n npleaseパスワード /n:"); int n1 = scanint(); if(n1 ==(123123)){system.out.println( "login rogin sucessfully/n"); showmain(); } else {system.out.println( "パスワードエラー"); system.out.println( "パスワードに再入力してください/n:");ログイン(); }} private static void showmain(){system.out.println( "/n/n/tショッピング管理システム/n");概要(); System.out.println( "/t/t1。メンバー情報管理/n"); System.out.println( "/t/t 2。商品情報管理/n"); System.out.println( "/t/t3。ShoppingSettlement/n"); System.out.println( "/t/t4。LogOut/n");概要(); System.out.print( "選択して、番号を入力してください:"); int n2 = scanint(); switch(n2){case 1:new user();壊す;ケース2:商品();壊す;ケース3:jiesuan();壊す;ケース4:system.out.println( "log out sucterfuly");メイン(null);デフォルト:system.out.println( "必要なオプションの再入力"); showmain();壊す; }} private static void goods(){//製品管理:製品の追加:番号付き製品名価格//削除:ラベルを選択してdelete outline(); System.out.println( "/t/t製品情報管理/n"); System.out.println( "/t/t1、display product/n"); system.out.println( "/t/t2、add item/n"); System.out.println( "/t/t3、delete product/n"); system.out.println( "/t/t4、前の/nに戻る");概要(); int n = scanint(); if(n == 1){showgoods(); } else if(n == 2){addgoods(); } else if(n == 3){delgoods(); } else if(n == 4){showmain(); } else {goods(); }} private static void delgoods(){system.out.println( "削除する製品のIDを選択してください: /nプレス0に前のレベルに戻る"); try {scanner scan = new Scanner(system.in); int x = scan.nextint(); boolean remove = false; for(int i = 0; i <array.size(); i ++){if(x == integer.parseint(array.get(i))){remove = true; }} if(remove){goodschildnode.remove(integer.tostring(x)); system.out.println( "delete ressuly");品(); } else if(x == 0){goods(); } else {system.out.println( "no this product!"); delgoods(); } new user(); } catch(Exception e){System.out.println( "番号を入力してください"); delgoods(); }} private static void showgoods(){try {int length = goodschildnode.keys()。length; syncread(); if(leng == 0){system.out.println( "no product"); } else {try {system.out.println( "現在"+goodschildnode.keys()。length+"product"); for(int i = 0; i <= goodschildnode.keys()。length; i ++){string shows = goodschildnode.get(array.get(i)、 ""); System.out.println(shows); System.out.println( "七時 - 七面鳥、そして七七日 - 七度節して七面お願いします─〜ちなみ、そして七面、そして七面お願いします七面GoodsChildNode.sync(); x == integer.parse(i)){n.nextint(999)+1} system。 "+id+"+name+"+firce+"+nuit(); Product "+goodschildnode.keys()。length+" series/n "+array+"/n "+array.size(); goods();} catch(Exception e){goods();}} static void jiesuan(){try {system.out.println(" if a a member a a a a a a a a seell a a select on in select 0 "" (x == 1){huiyuan = true; system.out.println( ") xhuiyuan = xhuiyuan = false} system.out.println(「割引購入アクティビティに参加する場所: "); 10元を10個以上購入するために10元 " +m); system.out.println(" 4:200元、交換に10元を追加します " +ss); system.out.println(" 5:200 Yuan、Exchangeに20元を追加); } catch(system.out.println( ") (huiyuan && xhuiyuan){system.out.println(「この消費のために20%オフ」)。消費 "); double x = s*0.9; system.out.println("割引が節約します: "+(sx)+" yuan ");} out.println("総消費量: "+s+" yuan "); showmain();} static void os(){scanint(){scanint(); (s+2){s> = 103){s+3); out、ss+10) main(null); static arraylist <string> arraylist <>()。 system.out.out.out.out.println( "/t/system); break; case 2: deluser(); break; case 3: show(); break; case 4: showMain(); break; default: System.out.println("No option you want! Please reselect"); new user(); break; } } catch (Exception e) { new user(); } } private void deluser() throws BackingStoreException { System.out.println("Please select the ID of the削除されるユーザー: /n前のレベルに戻るには0を押します "); try {scanner scan = new scanner(system.in); int x = scan.nextint(); boolean remove = false; (削除){integer.tostring(x)) number ") 0; i <= childnode.keys()。length; i ++){string shows = childnode.keys()[i]、 ""); System.out.println( "七七日 - 七七日 - 七七日 - 七度けることで、七面お願いします~aprent -ow多いくつかの七面から七面にとうなら、七面による─ブールそして七度けることで、七面お願い者(例外){}} steprences node.systemroot( "user"); 6桁のカード番号、年齢、電話番号 "); system.out.println("/t/tはライン壊しの区別を入力します "); syncread(); string name = scansstr(); int card = scanint(); int age = scanint(); string tel = scanstr(); and new and = new randual(); integer.tostring(n.nextint(999)+1); system.out.println( "current user"+childnode.keys+"bit/n"+array.size())より多くの学習資料については、特別なトピック「管理システム開発」に注意してください。
上記はこの記事のすべての内容です。みんなの学習に役立つことを願っています。誰もがwulin.comをもっとサポートすることを願っています。