Cet article partage le code spécifique de la mise en œuvre Java du système de gestion du shopping pour votre référence. Le contenu spécifique est le suivant
Contenu clé
Structure de la branche Java Exercice Dynamic Array Registry Reading, Writing and Deletion
Code:
Package sans fin; Importer java.util.arraylist; import java.util.random; / *** @ java01.person1.java * @author User: Endless Auteur: Endless * @version a créé l'heure: 26 juillet 2017 à 6:29:16 PM * // Implémentation du produit et de la gestion de l'information des membres (Add, Delete, Affichage) * // Implémentation du Setmarch Setmarch * java.util.scanner; import java.util.prefs.backingstoreException; import java.util.prefs.preferences; public class person {static int s; Boolean statique Huiyuan, Xhuiyuan; String statique bke = "pepsi cola", ke = "500 ml de bouteille de cola", m = "5 kg de farine", ss = "1 poêle supor sauté", o = "L'Oreal Toner Bottle"; statique arrayList <string> array = new ArrayList <string> (); Préférences statiques bourses de biens = préférences.Systemroot (). Node ("biens"); // Créer des préférences statiques de nœud bourse bourseChildNode = woodsnodes.node ("marchandises"); // Créer un nœud enfant public static void main (String [] args) {Outline (); System.out.println ("/ Twelcome to Utiliser le système de gestion du shopping"); System.out.println ("/ t1.login System / N / T2.Exit Program / N"); contour(); int n = scanInt (); if (n == 1) {login (); } else if (n == 2) {System.out.println ("Overy"); System.exit (0); } else {System.out.println ("s'il vous plaît reselect:"); Main (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 ("l'entrée est incorrecte, veuillez saisir le numéro:"); } return x; } public static String scanstr () {String x = null; Try {Scanner Scan = new Scanner (System.in); x = scan.next (); } catch (exception e) {System.out.println ("l'entrée est incorrecte, veuillez entrer la chaîne:"); } return x; } public static void Login () {System.out.println ("* * * * * * * * * * * * * * * * * * * * * * * * * * * nplease Entrez le mot de passe / n:"); int n1 = scanInt (); if (n1 == (123123))) {System.out.println ("Login Successfulply / N"); showmain (); } else {System.out.println ("Erreur de mot de passe"); System.out.println ("Veuillez réintégrer le mot de passe / n:"); se connecter(); }} private static void showmain () {System.out.println ("/ n / n / t Bienvenue pour utiliser le système de gestion du shopping / n"); contour(); System.out.println ("/ t / t 1. Management des informations / n"); System.out.println ("/ t / t 2. Gestion des informations sur les biens / n"); System.out.println ("/ t / t 3. Settlement d'achat / n"); System.out.println ("/ t / t 4. Log Out / n"); contour(); System.out.print ("Veuillez sélectionner, entrez le numéro:"); int n2 = scanInt (); switch (n2) {cas 1: nouvel utilisateur (); casser; Cas 2: marchandises (); casser; Cas 3: Jiesuan (); casser; Cas 4: System.out.println ("se déconnecter avec succès"); Main (null); Default: System.out.println ("Racontez l'option que vous voulez"); showmain (); casser; }} Private Static Void Goods () {// Gestion des produits: Ajouter des produits: Nom du produit numéroté System.out.println ("/ t / t Product Information Management / N"); System.out.println ("/ t / t1, affichage produit / n"); System.out.println ("/ t / t2, ajouter item / n"); System.out.println ("/ t / t3, supprimer le produit / n"); System.out.println ("/ t / t4, retour à précédent / n"); contour(); int n = scanInt (); if (n == 1) {showgoods (); } else if (n == 2) {addgoods (); } else if (n == 3) {delgoods (); } else if (n == 4) {showmain (); } else {biens (); }} private static void delgoods () {System.out.println ("Veuillez sélectionner l'ID du produit à supprimer: / n Appuyez sur 0 pour revenir au niveau précédent"); Try {Scanner Scan = new Scanner (System.in); int x = scan.nextint (); booléen retire = false; pour (int i = 0; i <array.size (); i ++) {if (x == Integer.ParseInt (array.get (i))) {disposé = true; }} if (retire) {brochildNode.Remove (Integer.ToString (x)); System.out.println ("Supprimer avec succès"); marchandises(); } else if (x == 0) {biens (); } else {System.out.println ("Non ce produit!"); Delgoods (); } nouvel utilisateur (); } catch (exception e) {System.out.println ("Veuillez entrer un nombre"); Delgoods (); }} private static void showgoods () {try {int Linard = betterchildNode.Keys (). Length; Syncread (); if (Leng == 0) {System.out.println ("aucun produit"); } else {try {System.out.println ("Actuellement, il y a" + gochschildNode.Keys (). Longueur + "Product"); for (int i = 0; i <= brochildNode.Keys (). Length; i ++) {String shows = brochildNode.get (array.get (i), ""); System.out.println (spectacles); Système.out.println ("ographier Seign GoodsChildNode.Sync (); if (x == Integer.Parseint (array.get (i))) {check (n.nextint (999) +1);}} System.out.println (/ t Carriage de retour de la ligne de retour "); "ID:" + ID + "Nom du produit:" + Nom + "Prix:" Price + "Unité:" + nuit); Produit "+ gochsChildNode.Keys (). Longueur +" série / n "+ array +" / n "+ array.size ()); biens ();} catch (exception e) {goches ();}} static void jiesuan () {try {System.out.println (" est-ce un membre? (x == 1) {Huiyuan = true; xhuiyuan = true;} else {xhuiyuan = false;} else if (x == 0) {huiyuan = false; System.out.println (où participer à l'activité d'achat de réduction: "); Plus de 10 yuans pour les achats de plus de 10 yuans "+ m); System.out.println (" 4: plus de 200 yuans, ajouter 10 yuans à échanger "+ ss); System.out.println (" 5: plus de 200 yuans, ajouter 20 yuan à échanger "+ o); System.out.println (" 0: pas plus de 200 yuan, s'il vous plaît sélectionner: / n "););); } Catch (exception e) {System.out.println (s'il vous plaît entrez le numéro "); (Huiyuan && xhuiyuan) {System.out.println ("Chers membres chanceux, profitez de 20% pour cette consommation"); Consommation "); double x = s * 0,9; System.out.println (" Discount vous sauve: "+ (sx) +" yuan ");} system.out.println (" le montant de consommation réel total: "+ s +" yuan "); if (s> = 52) {Out (bke, S + 2); Out (SS, S + 10); Main (null);} Classe statique User {static ArrayList <string> array = new ArrayList <> (); Utilisateur "); System.out.println (" / t / t2, supprimer l'utilisateur "); System.out.println (" / t / t3, afficher l'utilisateur "); System.out.println (" / t / t4, retour au niveau précédent "); Outline (); try {int x = scanInt (); switch (x) {case 1: add (); Break; case 2: Delluser (); case; Show (); Niveau "); essayez {Scanner Scan = new Scanner (System.in); int x = scan.nextint (); boolean retirait = false; for (int i = 0; i <array.size (); i ++) {if (x == Integer.ParseInt (array.get (i))) {retire = true;}} if (retire) { ChildNode.Remove (Integer.ToString (x)); DeLUSER ();}} Private Static Void Show () {Try {int Length = ChildNode.Keys (). 0; i <= childNode.Keys (). Length; i ++) {String shows = childNode.get (childNode.Keys () [i], ""); System.out.println ("ographier Seignat-proch --ase, prochab (Exception e) {}} private static void add () {préférences nœuds = préférences.SystemRoot (). Node ("utilisateur"); Numéro de carte, âge, numéro de téléphone "); System.out.println (" / t / t Entrez la distinction de rupture de ligne "); scanInt (); syncread (); String name = scanstr (); int card = scanInt (); int Age = scanInt () ChildNode.put (ID, "ID:" + ID + "Nom:" Nom + "Numéro de carte:" + Card + "Age:" + Age + "Téléphone:" + Tel); Utilisateur "+ childNode.Keys (). Longueur +" bit / n "+ array +" / n "+ array.size ()); nouvel utilisateur ();} catch (exception e) {nouvel utilisateur ();}}}}Pour plus de matériel d'apprentissage, veuillez faire attention au sujet spécial «développement du système de gestion».
Ce qui précède est tout le contenu de cet article. J'espère que cela sera utile à l'apprentissage de tous et j'espère que tout le monde soutiendra davantage Wulin.com.