超市购物管理系统(附图).pdf
《超市购物管理系统(附图).pdf》由会员分享,可在线阅读,更多相关《超市购物管理系统(附图).pdf(23页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、package com。mm。entity;import java。io.*;/商品类 SuppressWarnings(”serial)public class Goods implements Serializable private int No;/商品编号 private String name;/商品名称 private double price;/商品单价 private int amount;/商品数量 private String unit;/商品单位 public int getNo()return No;public void setNo(int no)No=no;publ
2、ic String getUnit()return unit;public void setUnit(String unit)this.unit=unit;public String getName()return name;public void setName(String name)this。name=name;public double getPrice()return price;public void setPrice(double price)this。price=price;public int getAmount()return amount;public void setA
3、mount(int amount)this。amount=amount;public Goods()public Goods(int No,String name,double price,String unit,int amount)this.No=No;this.name=name;this。price=price;this.amount=amount;this。unit=unit;=package com。mm。entity;import java.util。Scanner;import com.mm.manager。;/菜单类 public class Menu /商品库存管理菜单 p
4、ublic static final void goodsMenu()System。out。println(*欢迎登录青鸟超市管理系统*”);Scanner input=new Scanner(System.in);GoodsManger gm=new GoodsManger();boolean result=true;while(result)System.out。print(”请选择进行的操作:);System.out。print(1.商品入库);System.out。print(2。商品出库”);System.out.print(3.新增商品”);System。out.print(”4.
5、查询全部商品);System。out.print(”5.按序查询号查询);System.out.print(6.退出n”);switch(input.nextInt())case 1:gm。inStorage();break;case 2:gm。outStorage();break;case 3:gm.add();break;case 4:gm.check();break;case 5:gm.checkByNo();break;case 6:result=false;break;default:System。out.println(t 您的选择有误。”);/收银管理菜单 public stat
6、ic final void orderMenu()System。out.println(”*欢迎登录青鸟超市管理系统*);Scanner input=new Scanner(System。in);OrderManager om=new OrderManager();boolean result=true;while(result)System。out。print(请选择进行的操作:”);System。out.print(1.扫描商品”);System.out.print(2.修改数量);System。out.print(3.结账”);System.out.print(”4.退出n”);swit
7、ch(input。nextInt()case 1:om.scan();/执行扫描 break;case 2:om.modify();/修改数量 break;case 3:om.account();/结账 break;case 4:result=false;break;default:System。out。println(”t 您的选择有误。);=package com。mm。entity;/订单类 /public class Order private String name;/所购商品名称:(编号)+名称+单位 private int count;/所购商品数量 private double
8、 price;/单价 public String getName()return name;public void setName(String name)this.name=name;public int getCount()return count;public void setCount(int count)this。count=count;public double getPrice()return price;public void setPrice(double price)this.price=price;public Order()public Order(String nam
9、e,int count,double price)this.name=name;this。count=count;this.price=price;=package com.mm。entity;import java.io。Serializable;/*会员类:主要记录积分和会员号 /SuppressWarnings(”serial)public class Vip implements Serializable private int vipNo;private int score;public int getVipNo()return vipNo;public void setVipNo(
10、int vipNo)this。vipNo=vipNo;public int getScore()return score;public void setScore(int score)this.score=score;public Vip()public Vip(int vipNo,int score)this。vipNo=vipNo;this。score=score;=package com.mm。initialize;/通过这个类给本地初始化一个原始商品信息表(创建仓库)import java.io.FileOutputStream;import java.io。IOException;i
11、mport java。io.ObjectOutputStream;import java.util。ArrayList;import com。mm。entity。Goods;public class GoodsList SuppressWarnings(”unchecked)public static void main(String args)Goods goo0=new Goods(1001,脉动水蜜桃 ”,7.0,1.5L”,50);Goods goo1=new Goods(1002,”旺仔苹果 Q 糖”,2。5,”70g”,70);Goods goo2=new Goods(1003,吉
12、百芝麻油 ,9。5,”125ml”,20);Goods goo3=new Goods(1004,雀巢奶香咖啡”,1.5,13g,200);Goods goo4=new Goods(1005,”白玉内酯豆腐,1。0,”400g,15);Goods goo5=new Goods(1006,桃李熟切片 ”,6.5,”400g,10);Goods goo6=new Goods(1007,白玉黄豆芽 ”,2.4,350g”,20);Goods goo7=new Goods(1008,喜之郎果冻 ,10.5,”125g,50);ArrayList list=new ArrayList();try Obje
13、ctOutputStream oos=new ObjectOutputStream(new FileOutputStream(D:goods。txt”);list。add(goo0);list。add(goo1);list。add(goo2);list.add(goo3);list。add(goo4);list。add(goo5);list。add(goo6);list.add(goo7);oos。writeObject(list);oos。close();catch(IOException e)e.printStackTrace();=package com。mm.initialize;im
14、port java.io.FileNotFoundException;import java.io。FileOutputStream;import java.io。IOException;import java.io。ObjectOutputStream;import java.util。ArrayList;import com。mm。entity。Vip;/*用来创建一个存储会员信息的库 */public class VipList public static void main(String args)throws FileNotFoundException,IOException Vip
15、 v1=new Vip(2001,200);Vip v2=new Vip(2002,800);Vip v3=new Vip(2003,2000);Vip v4=new Vip(2004,2100);Vip v5=new Vip(2005,1200);Vip v6=new Vip(2006,3200);Vip v7=new Vip(2007,290);ArrayListVip list=new ArrayListVip();list.add(v1);list.add(v2);list.add(v3);list。add(v4);list.add(v5);list。add(v6);list。add(
16、v7);ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(”D:vip。txt”));oos.writeObject(list);oos.close();=package com。mm.client;import java。io。BufferedReader;import java.io.BufferedWriter;import java。io.IOException;import java。io.InputStreamReader;import java.io.OutputStreamWriter;impo
17、rt java。net.Socket;import java。net.UnknownHostException;import java.util.Scanner;import com。mm。entity。Menu;public class MrgClient public static String username;public static void main(String args)throws UnknownHostException,IOException Scanner input=new Scanner(System.in);Socket socket=new Socket(”l
18、ocalhost”,10001);BufferedReader br=new BufferedReader(new InputStreamReader(socket。getInputStream();BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));System.out。println(”请输入用户名:);username=input。next();System。out.println(”请输入密码:);String password=input。next();bw.wr
19、ite(username+”+”+password);bw.flush();socket.shutdownOutput();String reply=br.readLine();if(reply.equals(登录成功)System.out。println(reply);/进入库管员界面 Menu。goodsMenu();else if(reply.equals(load successed!”))System。out.println(reply);/进入收银员界面 Menu。orderMenu();else System.out.println(reply);bw。close();br。cl
20、ose();socket.close();=package com.mm。server;import java。io.IOException;import .ServerSocket;import java。net.Socket;public class MgrServer public static void main(String args)throws IOException ServerSocket ss=new ServerSocket(10001);Socket socket=null;/搞个死循环,让服务器一直监听端口 while(true)socket=ss.accept();
21、MgrThread st=new MgrThread(socket);/启动一次程序创建一个线程 st。start();=package com.mm.server;import java.io。;import java。net。Socket;public class MgrThread extends Thread private Socket socket;public MgrThread(Socket socket)this.socket=socket;public void run()try BufferedReader br=new BufferedReader(new InputS
22、treamReader(socket。getInputStream());BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream());String admin=br.readLine();System.out.println(有用户请求登录”);if(admin.equals(admin1+888888”)|admin.equals(”admin2+888888)|admin.equals(”admin3+888888))bw。write(登录成功”);bw.flush();else
23、 if(admin。equals(1001+888888”)|admin。equals(”1002+888888)|admin。equals(”1003+888888)bw。write(”load successed!);bw.flush();else bw。write(”用户名或者密码错误!);bw。flush();bw.close();br。close();socket.close();catch(IOException e)e。printStackTrace();=package com。mm.manager;import java.io。File;import java.io.File
24、InputStream;import java。io。FileNotFoundException;import java.io。FileOutputStream;import java.io.IOException;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.io.Serializable;import java.util。ArrayList;import java。util.Scanner;import com.mm.entity。Goods;/*商品管理类,包括对商品的入库,出
25、库,新增,删除,按编号查询,全部商品查询等 author Administrator */SuppressWarnings(”serial)public class GoodsManger implements Serializable public static final File f=new File(D:goods.txt”);public static ArrayList getList()ObjectInputStream ois=null;try ois=new ObjectInputStream(new FileInputStream(f));if(ois。available(
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 超市 购物 管理 系统 附图
限制150内