欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    Java基于socket网络编程的超市收银管理系统.docx

    • 资源ID:89133207       资源大小:35.73KB        全文页数:30页
    • 资源格式: DOCX        下载积分:20金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要20金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    Java基于socket网络编程的超市收银管理系统.docx

    package entity;import java.io.Serializable;/* * 收银类 * */SuppressWarnings("serial")public class Cash implements Serializable private String name;/ 商品名private String unit;/ 商品单位private int amount;/ 商品数量private double price;/ 商品单价private double money;/ 商品金额public Cash(String name, String unit, int amount, double price, double money) this.name = name;this.unit = unit;this.amount = amount;this.price = price;this.money = money;public String getName() return name;public void setName(String name) this.name = name;public String getUnit() return unit;public void setUnit(String unit) this.unit = unit;public int getAmount() return amount;public void setAmount(int amount) this.amount = amount;public double getPrice() return price;public void setPrice(double price) this.price = price;public double getMoney() return money;public void setMoney(double money) this.money = money;package entity;import java.io.Serializable;/* * 商品类 * */SuppressWarnings("serial")public class ShangPin implements Serializable private String number;/ 商品编号private String spname;/ 商品名称private double price;/ 商品单价private String unit;/ 单位private int amount;/ 数量public String getNumber() return number;public void setNumber(String number) this.number = number;public String getSpname() return spname;public void setSpname(String spname) this.spname = spname;public double getPrice() return price;public void setPrice(double price) this.price = price;public String getUnit() return unit;public void setUnit(String unit) this.unit = unit;public int getAmount() return amount;public void setAmount(int amount) this.amount = amount;public ShangPin(String number, String spname, double price, String unit,int amount) this.number = number;this.spname = spname;this.price = price;this.unit = unit;this.amount = amount;package entity;/* * 用户类 */import java.io.Serializable;SuppressWarnings("serial")public class User implements Serializable private String username;/ 用户名称private String password;/ 用户密码public String getUsername() return username;public void setUsername(String username) this.username = username;public String getPassword() return password;public void setPassword(String password) this.password = password;public User(String username, String password) this.username = username;this.password = password;package entity;import java.io.Serializable;/* * 会员类 * */SuppressWarnings("serial")public class Vip implements Serializable private String vipId;/ 会员卡号private int score;/ 会员积分public Vip(String vipId,int score)this.vipId = vipId;this.score = score;public String getVipId() return vipId;public void setVipId(String vipId) this.vipId = vipId;public int getScore() return score;public void setScore(int score) this.score = score;package socket;/* * 客户端类 * */import java.io.InputStream;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.io.OutputStream;import .Socket;import java.text.SimpleDateFormat;import java.util.Date;import java.util.HashMap;import java.util.Map;import java.util.Scanner;import entity.Cash;import entity.ShangPin;public class Client static Scanner input = new Scanner(System.in);private static Object receive;private static String username;static int count = 0;private static Object send(Map<String, String> map) throws Exception,Exception / 发送方法Socket s = new Socket("127.0.0.1", 8800);OutputStream os = s.getOutputStream();ObjectOutputStream oos = new ObjectOutputStream(os);oos.writeObject(map);InputStream is = s.getInputStream();ObjectInputStream ois = new ObjectInputStream(is);receive = ois.readObject();/ 关闭流oos.close();os.close();is.close();ois.close();return receive;public static void main(String args) throws Exception System.out.println("*欢迎使用青鸟超市管理系统*");System.out.println("1.登陆");System.out.println("2.退出系统");System.out.println("*请选择数字1/2*");while (true) int choose = input.nextInt();if (choose = 1) do System.out.print("用户名称:");username = input.next();System.out.print("用户密码:");String password = input.next();Map<String, String> map = new HashMap<String, String>();map.put("账号", username);map.put("密码", password);map.put("send", "登录");send(map);/ 库存管理员界面if ("管理员".equals(receive) System.out.println("*欢迎登录青鸟超市库存管理系统*");admin(); else if ("收银员".equals(receive) System.out.println("*欢迎登录青鸟超市收银系统*");cash(); else System.out.println("用户名或者密码输入错误!登录失败!"); while (true); else if (choose = 2) System.out.println("您已经退出系统!");break; else System.out.println("输入错误!请重新选择数字1/2:");private static void admin() throws Exception / 管理员int choose;while (true) System.out.println("请选择进行的操作:1.商品入库 t 2.商品出库 t 3.新增商品 t 4.查询所有商品 t 5.按编号查询商品 t 6.退出");choose = input.nextInt();/ 选择库存操作switch (choose) case 1:/ 入库in();break;case 2:/ 出库out();break;case 3:/ 新增add();break;case 4:/ 打印所有商品checkall();break;case 5:/ 按编号查询check();break;case 6:/ 退出System.out.println("谢谢使用!");break;default:System.out.println("对不起,您的输入有误,请重新输入!");break;SuppressWarnings("unchecked")private static void in() throws Exception / 入库System.out.print("输入商品编号:");String number = input.next();Map<String, String> map = new HashMap<String, String>();map.put("编号", number);map.put("send", "查询编号");send(map);if ("有此商品".equals(receive) System.out.print("入库数量:");String amount = input.next();if (num(amount) = true) int a = Integer.parseInt(amount);if (a >= 0) map.put("入库数量", amount);map.put("send", "入库");Map<String, ShangPin> map1 = (Map<String, ShangPin>) send(map);System.out.println("商品编号tt" + "商品名称tt" + "商品单价tt"+ "单位tt" + "数量");for (ShangPin iterable_element : map1.values() System.out.println(iterable_element.getNumber()+ "tt" + iterable_element.getSpname()+ "tt" + iterable_element.getPrice() + "tt"+ iterable_element.getUnit() + "tt"+ iterable_element.getAmount(); else System.out.println("出库数量有误!"); else System.out.println("没有此商品,请选择编号3:新增商品!");SuppressWarnings("unchecked")private static void out() throws Exception / 出库System.out.print("输入商品编号:");String number = input.next();Map<String, String> map = new HashMap<String, String>();map.put("编号", number);map.put("send", "查询编号");send(map);if ("有此商品".equals(receive) System.out.print("出库数量:");String amount = input.next();if (num(amount) = true) int a = Integer.parseInt(amount);if (a >= 0) map.put("出库数量", amount);map.put("send", "出库");send(map);Map<String, ShangPin> map1 = (Map<String, ShangPin>) receive;if (a <= map1.get(number).getAmount() System.out.println("商品编号tt" + "商品名称tt"+ "商品单价ttt" + "单位ttt" + "数量");for (ShangPin sp : map1.values() System.out.println(sp.getNumber() + "tt"+ sp.getSpname() + "tt" + sp.getPrice()+ "tt" + sp.getUnit() + "tt"+ sp.getAmount(); else System.out.println("库存不足,请核实,出库失败!");System.out.println("商品编号tt" + "商品名称tt" + "商品单价tt"+ "单位tt" + "数量");System.out.println(map1.get(number).getNumber()+ "tt" + map1.get(number).getSpname()+ "tt" + map1.get(number).getPrice() + "tt"+ map1.get(number).getUnit() + "tt"+ map1.get(number).getAmount(); else System.out.println("出库数量有误!"); else System.out.println("没有此商品!");SuppressWarnings("unchecked")private static void add() throws Exception / 新增while (true) System.out.print("输入商品编号:");String number = input.next();Map<String, String> map = new HashMap<String, String>();map.put("编号", number);map.put("send", "查询编号");send(map);if ("无此商品".equals(receive) System.out.print("输入商品名称:");String spname = input.next();System.out.print("输入商品价格:");String price = input.next();if (price(price) = true) System.out.print("输入商品单位:");String unit = input.next();System.out.print("输入商品数量:");String amount = input.next();if (num(amount) = true) map.put("send", "新增");map.put("名称", spname);map.put("价格", price);map.put("单位", unit);map.put("数量", amount);send(map);System.out.println("新增商品成功!");Map<String, ShangPin> map2 = (Map<String, ShangPin>) receive;System.out.println("商品编号tt" + "商品名称tt"+ "商品单价ttt" + "单位ttt" + "数量");for (ShangPin sp : map2.values() System.out.println(sp.getNumber() + "tt"+ sp.getSpname() + "tt" + sp.getPrice()+ "tt" + sp.getUnit() + "tt"+ sp.getAmount();break; else System.out.println("此编号已存在");continue;SuppressWarnings("unchecked")private static void checkall() throws Exception / 查询全部Map<String, String> map = new HashMap<String, String>();map.put("send", "查询全部");send(map);Map<String, ShangPin> map1 = (Map<String, ShangPin>) receive;System.out.println("商品编号tt" + "商品名称tt" + "商品单价tt" + "单位tt"+ "数量");for (ShangPin sp : map1.values() System.out.println(sp.getNumber() + "tt" + sp.getSpname()+ "tt" + sp.getPrice() + "tt" + sp.getUnit() + "tt"+ sp.getAmount();SuppressWarnings("unchecked")private static void check() throws Exception / 查询号查询System.out.print("输入商品编号:");String number = input.next();Map<String, String> map = new HashMap<String, String>();map.put("编号", number);map.put("send", "查询编号");send(map);if ("有此商品".equals(receive) map.put("send", "查询号查询");send(map);Map<String, ShangPin> map1 = (Map<String, ShangPin>) receive;System.out.println("商品编号tt" + "商品名称tt" + "商品单价ttt"+ "单位ttt" + "数量");for (ShangPin sp : map1.values() System.out.println(sp.getNumber() + "tt" + sp.getSpname()+ "tt" + sp.getPrice() + "tt" + sp.getUnit()+ "tt" + sp.getAmount(); else System.out.println("对不起,没有此商品!");private static void cash() throws Exception / 收银int choose;while (true) System.out.println("请选择进行的操作:1.扫描商品 t 2.修改数量 t 3.结账 t 4.退出");choose = input.nextInt();/ 选择库存操作switch (choose) case 1:/ 扫描scan();break;case 2:/ 修改数量modify();break;case 3:/ 新增checkout();break;case 4:/ 退出System.out.println("谢谢使用!");break;default:System.out.println("对不起,您的输入有误,请重新输入!");break;SuppressWarnings("unchecked")public static void scan() throws Exception / 扫描商品System.out.print("输入需要扫描的商品编号:");String number = input.next();Map<String, String> map = new HashMap<String, String>();map.put("编号", number);map.put("send", "查询编号");send(map);if ("有此商品".equals(receive) System.out.println("扫描成功!");count+;String c = String.valueOf(count);map.put("send", "扫描");map.put("扫描次数", c);send(map);Map<String, Cash> map2 = (Map<String, Cash>) receive;System.out.println("商品名称tttt" + "数量tt" + "单价tt" + "金额");System.out.println("-");for (Cash cash : map2.values() System.out.println(cash.getName() + cash.getUnit() + "tt"+ cash.getAmount() + "tt" + cash.getPrice() + "tt"+ cash.getMoney();System.out.println("-"); else System.out.println("对不起,没有此商品,扫描失败");SuppressWarnings("unchecked")public static void modify() throws Exception / 修改购买数量Map<String, String> map = new HashMap<String, String>();if (count != 0) while (true) System.out.print("输入需要修改的商品编号:");String number = input.next();map.put("编号", number);map.put("send", "查询编号");send(map);if ("有此商品".equals(receive) map.put("编号", number);map.put("send", "检测是否扫描");send(map);if ("已被扫描".equals(receive) System.out.print("输入修改数量:");String amount = input.next();if (num(amount) = true) int a = Integer.parseInt(amount);if (a >= 0) map.put("数量", amount);map.put("send", "修改数量");send(map);Map<String, Cash> map2 = (Map<String, Cash>) receive;System.out.println("商品名称tttt" + "数量tt"+ "单价tt" + "金额");System.out.println("-");for (Cash cash : map2.values() System.out.println(cash.getName()+ cash.getUnit() + "tt"+ cash.getAmount() + "tt"+ cash.getPrice() + "tt"+ cash.getMoney();System.out.println("-"); else System.out.println("修改数量有误!");break;break; else System.out.println("没有扫描此商品。");continue; else System.out.println("对不起,没有此商品,扫描失败!");break; else System.out.println("您还没有扫描商品!");SuppressWarnings("unchecked")public static void checkout

    注意事项

    本文(Java基于socket网络编程的超市收银管理系统.docx)为本站会员(叶***)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开