超市购物管理系统附图.docx
- 文档编号:25980227
- 上传时间:2023-06-16
- 格式:DOCX
- 页数:34
- 大小:109.90KB
超市购物管理系统附图.docx
《超市购物管理系统附图.docx》由会员分享,可在线阅读,更多相关《超市购物管理系统附图.docx(34页珍藏版)》请在冰豆网上搜索。
超市购物管理系统附图
package;
importjava.io.*;
//商品类
@SuppressWarnings("serial")
publicclassGoodsimplementsSerializable{
privateintNo;//商品编号
privateStringname;//商品名称
privatedoubleprice;//商品单价
privateintamount;//商品数量
privateStringunit;//商品单位
publicintgetNo(){
returnNo;
}
publicvoidsetNo(intno){
No=no;
}
publicStringgetUnit(){
returnunit;
}
publicvoidsetUnit(Stringunit){
this.unit=unit;
}
publicStringgetName(){
returnname;
}
publicvoidsetName(Stringname){
this.name=name;
}
publicdoublegetPrice(){
returnprice;
}
publicvoidsetPrice(doubleprice){
this.price=price;
}
publicintgetAmount(){
returnamount;
}
publicvoidsetAmount(intamount){
this.amount=amount;
}
publicGoods(){}
publicGoods(intNo,Stringname,doubleprice,Stringunit,intamount){
this.No=No;
this.name=name;
this.price=price;
this.amount=amount;
this.unit=unit;
}
}
=====================================================================
package;
import;
import.*;
//菜单类
publicclassMenu{
//商品库存管理菜单
publicstaticfinalvoidgoodsMenu(){
("*****欢迎登录青鸟超市管理系统*****");
Scannerinput=newScanner(System.in);
GoodsMangergm=newGoodsManger();
booleanresult=true;
while(result){
("请选择进行的操作:
");
("1.商品入库");
("2.商品出库");
("3.新增商品");
("4.查询全部商品");
("5.按序查询号查询");
("6.退出\n");
switch(input.nextInt()){
case1:
gm.inStorage();
break;
case2:
gm.outStorage();
break;
case3:
gm.add();
break;
case4:
gm.check();
break;
case5:
gm.checkByNo();
break;
case6:
result=false;
break;
default:
("\t您的选择有误。
");
}
}
}
//收银管理菜单
publicstaticfinalvoidorderMenu(){
("*****欢迎登录青鸟超市管理系统*****");
Scannerinput=newScanner(System.in);
OrderManagerom=newOrderManager();
booleanresult=true;
while(result){
("请选择进行的操作:
");
("1.扫描商品");
("2.修改数量");
("3.结账");
("4.退出\n");
switch(input.nextInt()){
case1:
om.scan();//执行扫描
break;
case2:
om.modify();//修改数量
break;
case3:
om.account();//结账
break;
case4:
result=false;
break;
default:
("\t您的选择有误。
");
}
}
}
}
=====================================================================
package;
/*
*订单类
*/
publicclassOrder{
privateStringname;//所购商品名称:
(编号)+名称+单位
privateintcount;//所购商品数量
privatedoubleprice;//单价
publicStringgetName(){
returnname;
}
publicvoidsetName(Stringname){
this.name=name;
}
publicintgetCount(){
returncount;
}
publicvoidsetCount(intcount){
this.count=count;
}
publicdoublegetPrice(){
returnprice;
}
publicvoidsetPrice(doubleprice){
this.price=price;
}
publicOrder(){}
publicOrder(Stringname,intcount,doubleprice){
this.name=name;
this.count=count;
this.price=price;
}
}
===================================================
package;
import;
/**
*会员类:
主要记录积分和会员号
*/
@SuppressWarnings("serial")
publicclassVipimplementsSerializable{
privateintvipNo;
privateintscore;
publicintgetVipNo(){
returnvipNo;
}
publicvoidsetVipNo(intvipNo){
this.vipNo=vipNo;
}
publicintgetScore(){
returnscore;
}
publicvoidsetScore(intscore){
this.score=score;
}
publicVip(){}
publicVip(intvipNo,intscore){
this.vipNo=vipNo;
this.score=score;
}
}
====================================================
package;
//通过这个类给本地初始化一个原始商品信息表(创建仓库)
import;
import;
import;
import;
import;
publicclassGoodsList{
@SuppressWarnings("unchecked")
publicstaticvoidmain(String[]args){
Goodsgoo0=newGoods(1001,"脉动水蜜桃",7.0,"1.5L",50);
Goodsgoo1=newGoods(1002,"旺仔苹果Q糖",2.5,"70g",70);
Goodsgoo2=newGoods(1003,"吉百芝麻油",9.5,"125ml",20);
Goodsgoo3=newGoods(1004,"雀巢奶香咖啡",1.5,"13g",200);
Goodsgoo4=newGoods(1005,"白玉内酯豆腐",1.0,"400g",15);
Goodsgoo5=newGoods(1006,"桃李熟切片",6.5,"400g",10);
Goodsgoo6=newGoods(1007,"白玉黄豆芽",2.4,"350g",20);
Goodsgoo7=newGoods(1008,"喜之郎果冻",10.5,"125g",50);
ArrayList
try{
ObjectOutputStreamoos=newObjectOutputStream(
newFileOutputStream(
"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(IOExceptione){
e.printStackTrace();
}
}
}
============================================================
package;
import;
import;
import;
import;
import;
import;
/*
*用来创建一个存储会员信息的库
*/
publicclassVipList{
publicstaticvoidmain(String[]args)throwsFileNotFoundException,IOException{
Vipv1=newVip(2001,200);
Vipv2=newVip(2002,800);
Vipv3=newVip(2003,2000);
Vipv4=newVip(2004,2100);
Vipv5=newVip(2005,1200);
Vipv6=newVip(2006,3200);
Vipv7=newVip(2007,290);
ArrayList
list.add(v1);
list.add(v2);
list.add(v3);
list.add(v4);
list.add(v5);
list.add(v6);
list.add(v7);
ObjectOutputStreamoos=newObjectOutputStream(newFileOutputStream("D:
\\vip.txt"));
oos.writeObject(list);
oos.close();
}
}
=====================================================
package;
import;
import;
import;
import;
import;
import;
import;
import;
import;
publicclassMrgClient{
publicstaticStringusername;
publicstaticvoidmain(String[]args)throwsUnknownHostException,IOException{
Scannerinput=newScanner(System.in);
Socketsocket=newSocket("localhost",10001);
BufferedReaderbr=newBufferedReader(newInputStreamReader(socket.getInputStream()));
BufferedWriterbw=newBufferedWriter(newOutputStreamWriter(socket.getOutputStream()));
("请输入用户名:
");
username=input.next();
("请输入密码:
");
Stringpassword=input.next();
bw.write((username+"+"+password));
bw.flush();
socket.shutdownOutput();
Stringreply=br.readLine();
if(reply.equals("登录成功")){
(reply);
//进入库管员界面
Menu.goodsMenu();
}elseif(reply.equals("loadsuccessed!
")){
(reply);
//进入收银员界面
Menu.orderMenu();
}else{
(reply);
}
bw.close();
br.close();
socket.close();
}
}
=========================================================
package;
import;
import;
import;
publicclassMgrServer{
publicstaticvoidmain(String[]args)throwsIOException{
ServerSocketss=newServerSocket(10001);
Socketsocket=null;
//搞个死循环,让服务器一直监听端口
while(true){
socket=ss.accept();
MgrThreadst=newMgrThread(socket);//启动一次程序创建一个线程
st.start();
}
}
}
====================================================================
package;
importjava.io.*;
import;
publicclassMgrThreadextendsThread{
privateSocketsocket;
publicMgrThread(Socketsocket){
this.socket=socket;
}
publicvoidrun(){
try{
BufferedReaderbr=newBufferedReader(newInputStreamReader(socket.getInputStream()));
BufferedWriterbw=newBufferedWriter(newOutputStreamWriter(socket.getOutputStream()));
Stringadmin=br.readLine();
("有用户请求登录");
if(admin.equals("admin1+888888")||admin.equals("admin2+888888")||admin.equals("admin3+888888")){
bw.write("登录成功");
bw.flush();
}
elseif(admin.equals("1001+888888")||admin.equals("1002+888888")||admin.equals("1003+888888")){
bw.write("loadsuccessed!
");
bw.flush();
}
else{
bw.write("用户名或者密码错误!
");
bw.flush();
}
bw.close();
br.close();
socket.close();
}catch(IOExceptione){
e.printStackTrace();
}
}
}
======================================================
package;
import;
import;
import;
import;
import;
import;
import;
import;
import;
import;
import;
/**
*商品管理类,包括对商品的入库,出库,新增,删除,按编号查询,全部商品查询等
*@authorAdministrator
*
*/
@SuppressWarnings("serial")
publicclassGoodsMangerimplementsSerializable{
publicstaticfinalFilef=newFile(
"D:
\\goods.txt");
publicstaticArrayList
//获取本地库存列表
@SuppressWarnings("unchecked")
publicsynchronizedstaticArrayList
ObjectInputStreamois=null;
try{
ois=newObjectInputStream(newFileInputStream(f));
if(ois.available()!
=-1)
list=(ArrayList
elseois.close();
}catch(ClassNotFoundExceptione){
e.printStackTrace();
}catch(IOExceptione){
e.printStackTrace();
}finally{
if(ois!
=null)
try{
ois.close();
}catch(IOExceptione){
e.printStackTrace();
}
}
returnlist;
}
//查询全部商品
publicvoidcheck(){
list=getList();
//打印菜单表头
("商品编号\t"+"商品名称\t\t\t"+"商品单价\t\t"+"单位\t\t"+"数量");
//打印菜单列表----遍历读来的ArrayList集合
for(Goodss:
list){
if(s.getName().length()<5)
(s.getNo()+"\t"+s.getName()+"\t\t\t"
+s.getPrice()+"\t\t"+s.getUnit()+"\t\t"+s.getAmount());
else
(s.getNo()+"\t"+s.getName()+"\t\t"
+s.getPrice()+"\t\t"+s.getUnit()+"\t\t"+s.getAmount());
}
}
//商品入库(要传入编号)
publicsynchronizedvoidinStorage(){
list=getList();
ObjectOutputStreamoos=null;
try{
oos=newObjectOutputStream(newFileOutputStream(f));
}catch(FileNotFoundExceptione1){
e1.printStackTrace();
}catch(IOExceptione1){
e1.printStackTrace();
}
//遍历ArrayList若送来的商品在库中存在则改变:
原有数量=原有数量+新增数量,否则提示选择新增商品
booleancontain=false;//作为原库中是否包含有此新增商品的标记,默认不包含
//包含就只改变数目
("请输入商品编号:
");
Scannerinput=newScanner(System.in);
intNo=input.nextInt();
for(inti=0;i if(contain=(No==list.get(i).getNo())){ ("入库数量: "); intamount=input.nextInt(); (list.get(i)).setAmount(list.get(i).getAmount() +amount);//更新原有数量=原有数量+新增数量 ("入库成功! "); try{ oos.writeObject(list); oos.flush(); }catch(IOExceptione){ e.printStackTrace(); } break; } } if(! contain){ ("请选择编号3: 新增商品"); } } //商品出库(要传入编号) publicsynchronizedvoidoutStorage(){ list=getList(); ObjectOutputStreamoos=null; try{ oos=newObjectOutputStream(newFileOutputStream(f)); }catch(FileNotFoundExceptione1){ e1.printStackTrace(); }catch(IOExceptione1){ e1.printStackTrace(); } booleancontain=false;//作为原库中是否包含有此新增商品的标记,默认不包含 Scannerinput=newScanner(System.in); do{ ("请输入商品编号: "); intNo=input.nextInt();
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 超市 购物 管理 系统 附图