Write to stay Business Supermarket management system ~ ~ ~ The first part

Source: Internet
Author: User

requirements See: Http://pan.baidu.com/s/1pJPsYF5

Have the opportunity to fill PO to the blog above ~

First use the menu to set up the frame after entering

/* * */package com.pb.menu;public class Menu {/** * login menu */public void login () {System.out.println ("Welcome to use Super Management system") System.out.println ("1, landing system"); System.out.println ("2, Exit");} /** * Main Menu contents */public void MainMenu () {System.out.println ("********** I was split line ***********"); System.out.println ("1, product maintenance"); System.out.println ("2, front desk cashier"); System.out.println ("3, Commodity Management"); System.out.println ("4, return to the previous menu"); System.out.println ("********** I am the dividing line ***********");} /** * Product Maintenance menu contents */public void Mainmenu_1 () {System.out.println ("Commercial super Shopping system >>> product maintenance"); System.out.println ("********** I am the dividing line ***********"); System.out.println ("1, increase commodity information"); System.out.println ("2, change of product information"); System.out.println ("3, delete product information"); System.out.println ("4, Show All product Information"); System.out.println ("5, Inquiry product Information"); System.out.println ("6, storage Management"); System.out.println ("7, Save"); System.out.println ("8, return to the previous menu"); System.out.println ("********** I am the dividing line ***********");} /** * Front cashier menu contents */public void Mainmenu_2 () {System.out.println ("Business overbought system >>> foreground cashier"); System.out.println ("********** I am the dividing line ***********"); System.out.println ("1, shopping settlement"); System.out.println ("2, return to the previous menu"); System.out.println ("********** I am the dividing line ***********");} /** * Product Maintenance menu contents */public void Mainmenu_3 () {System.out.println ("Commercial super Shopping system >>> commodity Management"); System.out.println ("********** I am the dividing line ***********"); System.out.println ("1, set commodity alert inventory"); System.out.println ("2, Goods Sold Today"); System.out.println ("3, Salesperson Management"); System.out.println ("4, return to the previous menu"); System.out.println ("********** I am the dividing line ***********");} public void Mainmenu_3_3 () {System.out.println ("Commercial super Shopping system >>> Commodity management >>> Salesperson Management"); System.out.println ("********** I am the dividing line ***********"); System.out.println ("1, new salesperson Information"); System.out.println ("2, modify sales Information"); System.out.println ("3, delete sales information"); System.out.println ("4, Show All salesman Information"); System.out.println ("5, View salesman information"); System.out.println ("6, save"); System.out.println ("7, Return to the previous menu"); System.out.println ("********** I am Split line ***********");}}

Then my train of thought is very linear, wrote the writing structure on the paper, probably is two things, a call salesman, is used to manipulate the item, one is called good, is the item.

I use a class called user to manage the methods and properties that store both of them. And then manage the calls separately.

So I first write out the main function, and then write about each of the missing parts.

Package Com.pb.user;import Java.util.scanner;import Com.pb.good.good;import com.pb.goodbiz.goods;import Com.pb.isinputright.isright;import Com.pb.management.goodmanagement;import com.pb.management.SalesmanManagement; Import Com.pb.myexception.myexception;import Com.pb.salesman.salesman;import com.pb.salesmanBiz.SalesmanGroup; public class User {Scanner in = new Scanner (system.in); Goodmanagement gm = new Goodmanagement (); Salesmanmanagement sm = new Salesmanmanagement ();//Login Main Menu public boolean Landingman () {System.out.print ("Please enter user name:"); String name = In.next (); System.out.print ("\ n Please enter your password:"); String psd = In.next (), if (Name.equals ("admin")) {if (Psd.equals ("admin")) return true;} return false;} Shop Assistant Login Public boolean landing () {System.out.print ("Please enter user name:"); String name = In.next (); System.out.print ("\ n Please enter your password:"); String psd = In.next (); try {if (SalesmanGroup.userMap.get (name) = = null) throw new MyException ("Username password does not match!") ");} catch (MyException e) {System.out.println (E.getmessage ()); return false;} try {if (! SalesmaNGroup.userMap.get (name). GETPSD (). Equals (PSD)) throw new MyException ("Username password does not match!"). ");} catch (MyException e) {System.out.println (E.getmessage ()); return false;} return true;} New Product public void Add () {System.out.println ("Please Enter product information:"); System.out.println ("Please enter product Name:"); String name = In.next (); try {if (Goods.goodMap.get (name) = null) throw new MyException ("Username already exists! ");} catch (MyException e) {System.out.println (E.getmessage ()); return;} System.out.println ("Please enter commodity price:");d ouble prices = in.nextdouble (); System.out.println ("Please enter commodity stock:"), int storage = In.nextint (); Gm.add (new Good (name, price, storage));} Delete commodity public void Delete () {System.out.println ("Please enter product Name:"); String name = In.next (), if (Goods.goodMap.get (name) = null) {if (Goods.goodMap.get (name). GetStorage () = = 0) {gm.delete (n AME);} else {System.out.println ("The inventory is not 0, you cannot delete the product! ");}} else {System.out.println ("the product does not exist! ");}} Modify commodity public void modify () {System.out.println ("Please enter the product name:"); String name = In.next (); if (Goods.goodMap.get (name) = null) {gm.query (name); String C;do {System.out.println ("Please select the content you want to modify:"); System.out.println ("1, change the name of the product:"); System.out.println ("2, change the price of the Goods:"); System.out.println ("3, change the quantity of goods:"); int n = in.nextint (); switch (n) {case 1:system.out.println ("Please enter the changed product name:"); String newname = In.next (); Good good = Goods.goodMap.get (name); Good.setname (newname); Goods.goodMap.remove (name); Goods.goodMap.put (newname, good); Break;case 2:system.out.println ("Please enter the price of the changed product:"); Goods.goodMap.get (name). Setprice (In.nextdouble ()) break;case 3:system.out.println ("Please enter the quantity of goods after change:"); Goods.goodMap.get (name). Setstorage (In.nextint ()); System.out.print ("Whether to continue modifying this product information (n/y):"); c = In.next ();} while (C.equalsignorecase ("Y"));} ELSESYSTEM.OUT.PRINTLN ("The product does not exist, please verify!") ");} View specified goods public void query () {System.out.println ("Please enter product Name:"); String name = In.next (); if (Goods.goodMap.get (name)! = null) {gm.query (name);} elseSystem.out.println ("The product does not exist, please verify!") ");} Query public void Pricequery () {gm.pricequery () by Price Ascending;} View all Products public void Queryall () {Gm.queryall ();} Check the same day buy goods public void Dayquery () {Gm.dayQuery ();} Fuzzy Find commodity Information public boolean fuzzyquery () {System.out.println ("Please enter commodity keywords:"); String str = In.next (); return gm.fuzzyquery (str);} Save commodity Information public void Save () {Gm.save ();} Commodity entry public void in () {System.out.println ("Please enter product Name:"); String name = In.next (), if (Goods.goodMap.get (name)! = null) {System.out.println ("Please Enter inbound quantity:"); int num = In.nextint (); gm.in (name, num);} ELSESYSTEM.OUT.PRINTLN ("The product does not exist! ");} New Salesperson public void Addsalesman () {System.out.println ("Please enter salesperson information:"); System.out.println ("Please enter user name:"); String name = In.next (); try {if (SalesmanGroup.userMap.get (name) = null) throw new MyException ("The user already exists!") ");} catch (MyException e) {System.out.println (E.getmessage ()); return;} System.out.println ("Please enter password:"); String psd = In.next (); if (! ISRIGHT.ISPSD (PSD)) return; System.out.println ("Please enter your password again:"); String PSD1 = In.next (); if (! ISRIGHT.ISPSD (PSD, PSD1)) return; System.out.println ("Please enter Age:"); int = In.nextint (); Isright.isage (age)) Return;sm.add (The new salesman (name, PSD, age));} Modify Salesperson public void Modifysalesman (){System.out.println ("Please enter user name:"); String name = In.next (); if (SalesmanGroup.userMap.get (name) = null) {sm.query (name); String C;do {System.out.println ("Please select what you want to modify:"); System.out.println ("1, change user name:"); System.out.println ("2, Change Password:"); System.out.println ("3, Change Age:"), int n = in.nextint (), switch (n) {case 1:system.out.println ("Please enter the changed username"); String newname = In.next (); Salesman salesman = SalesmanGroup.userMap.get (name); Salesman.setname (newname); SalesmanGroup.userMap.remove (name); SalesmanGroup.userMap.put (newname, salesman); Break;case 2:system.out.println ("Please enter the changed password:"); SalesmanGroup.userMap.get (name). SETPSD (In.next ()) break;case 3:system.out.println ("Please enter the age after Change:"); SalesmanGroup.userMap.get (name). Setage (In.nextint ()); System.out.print ("Whether to continue modifying this user information (n/y):"); c = In.next ();} while (C.equalsignorecase ("Y"));} ElseSystem.out.println ("User name does not exist! ");} Delete salesperson public void Deletesalesman () {System.out.println ("Please enter the user name to delete:"); String name = In.next (); if (SalesmanGroup.userMap.get (name)! = null) {Salesmangroup.usermap. Remove (name); ElseSystem.out.println ("User name does not exist! ");} Find the specified salesperson public void Querysalesman () {System.out.println ("Please enter the user name to query:"); String name = In.next (), if (SalesmanGroup.userMap.get (name)! = null) {sm.query (name);} elseSystem.out.println ("username does not exist! ");} Find all salespersons public void Queryallsalesman () {Sm.queryall ();} Save public void Savesalesman () {Sm.save ();} Check commodity inventory public void checkstorage (int num) {gm.checkstorage (num);} Shopping public double settlement () {System.out.println ("Please enter product Name:"); String name = In.next (), if (Goods.goodMap.get (name) = = null) {System.out.println ("the product does not exist!") "); return 0;} else {System.out.println ("Please enter purchase quantity:"), int sale = In.nextint (); return Gm.settlement (Goods.goodMap.get (name), sale);}} Payment public void Payment () {Double sum = 0;//Total amount of purchase item double SUM1 = 0;//Total fee Double money = 0;//Single Payment amount string C;do {if (fu Zzyquery ()) {sum + = settlement ();} else {System.out.println ("the product does not exist! ");} System.out.print ("Whether to continue to purchase (n/y):"); c = In.next ();} while (C.equalsignorecase ("Y")), if (sum = = 0) System.out.println ("Welcome Again"), else {do {System.out.println ("Enter payment amount:"); money = In.nextdouble (); Sum1 + = money;if (sum1 < sum) SYSTEM.OUT.PRINTLN ("Payment is less than the amount of money, please continue to pay!" ");} while (Sum1 < sum); System.out.println ("Change:" + (sum1-sum) + "\ n Welcome again");}}}
And then we'll write their management.

—————————————————— Gorgeous split-line ——————————————————————

/** * Manage commodity repositories */package Com.pb.management;import Com.pb.good.good;import Com.pb.goodbiz.goods;public class goodmanagement {Goods Goods = new Goods ();//new public void Add (good good) {Goods.addgood (good);} Delete public void Delete (String name) {Goods.deletegood (name);} Modify public void Modify (good good) {Goods.modifygood (good);} Query specified goods public void query (String name) {Goods.querygood (name);} Query all goods public void Queryall () {Goods.queryall ();} Search for the same day buy goods public void Dayquery () {goods.dayquery ();} Ascending find commodity public void pricequery () {goods.pricequery ();} Fuzzy Lookup Commodity Information public boolean fuzzyquery (String str) {return goods.fuzzyquery (str);} Save public void Save () {Goods.save ();} Inbound public void in (String name, int num) {goods.in (name, num);} Check commodity inventory public void checkstorage (int num) {goods.checkstorage (num);} Checkout public double settlement (good good, int sale) {return goods.settlement (good, Sale);}}

/** * Management shop Assistant Library */package com.pb.management;import Com.pb.salesman.salesman;import com.pb.salesmanBiz.SalesmanGroup; public class Salesmanmanagement {salesmangroup sg = new Salesmangroup ();//new Salesperson public void Add (salesman user) {Sg.add (use R);} Modify Salesperson public void modity (salesman user) {sg.modify (user);} Delete salesperson public void Delete (String name) {sg.delete (name);} Find the specified salesperson public void query (String name) {sg.query (name);} Find all salespersons public void Queryall () {Sg.queryall ();} Save public void Save () {Sg.save ();}}

Write to here first, the concrete bottom operation please see next!

Write to stay Business Supermarket management system ~ ~ ~ The first part

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.