




已阅读5页,还剩25页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
此文档收集于网络,如有侵权,请联系网站删除软 件 学 院课程设计报告书 2011 年 6 月目录1 设计时间32 设计目的33设计任务33.1任务说明33.2系统目标33.3使用范围34 设计内容34.1界面构建34.2详细设计34.2.1模块设计44.2.2运行调试44.2.3部分源程序85 总结与展望28参考文献29成绩评定291 设计时间2011年6月11日-2011年6月15日2 设计目的通过实践加深学生对面向对象程序设计的理论、方法和基础知识的理解,掌握使用Java语言进行面向对象设计的基本方法,提高运用面向对象知识分析实际问题、解决实际问题的能力,提高学生的应用能力。3设计任务3.1任务说明设计出一个超市收银程序(1)使用图形用户界面实现。信息返回给收银台,计算出该顾客所购商品的总价格。(3)每天营业结束把该收银台的销售总额进行统计汇总(要求包括商品种类、数量、销售总额、结账人次等信息,其余可自行丰富)并存储在数据库中。(4)所有持卡顾客的消费商品情况存储到文件以供查询。(5)对没有卡的消费情况不记录该顾客的消费情况等个人信息。如果一个未持卡顾客一次购物满200元,结完账后系统提示可为其发放一张会员卡3.2系统目标该软件开发的用途是用来方便超市的收银管理,提高办事效率。3.3使用范围本程序用于超市对会员和非会员的销售管理4 设计内容 4.1界面构建为了便于各种操作,软件采用多窗口的模式。用户可在不同窗口进行相应操作。4.2详细设计4.2.1模块设计 用户登录确认密码操作界面输入商品编号删除商品修改数量修改价格完成结算会员结算否是销售情况4.2.2运行调试图1登录界面图2操作界面图3.1修改数量图3.2 填入要修改数量的商品号图3.3输入新数量图4.1 普通结算图4.2会员结算图5销售情况图6系统时间4.2.3部分源程序登录import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.StringTokenizer;import javax.swing.*;public class land public static void main(String args) landframe frame = new landframe();frame.setTitle(收营员登陆);frame.setLocation(300,300);frame.setSize(270, 170);frame.setVisible(true);class landframe extends JDialog implements ActionListener public landframe() label1 = new JLabel(JAVA超市收营系统 请登陆);label2 = new JLabel(用户名:);label3 = new JLabel(密码:);hbox1 = Box.createHorizontalBox();hbox2 = Box.createHorizontalBox();vbox = Box.createVerticalBox();jf1 = new JTextField();JPF= new JPasswordField();JPF.addActionListener(this);land = new JButton(登陆);land.addActionListener(this);panel1 = new JPanel();panel2 = new JPanel();hbox1.add(label2);hbox1.add(Box.createHorizontalStrut(5);hbox1.add(jf1);hbox2.add(label3);hbox2.add(Box.createHorizontalStrut(18);panel2.add(land, Center);hbox2.add(JPF);vbox.add(label1);vbox.add(Box.createVerticalStrut(10);vbox.add(hbox1);vbox.add(Box.createVerticalStrut(10);vbox.add(hbox2);vbox.add(Box.createVerticalStrut(10);vbox.add(panel2);panel1.add(vbox);getContentPane().add(panel1, Center);public void actionPerformed(ActionEvent evt) Object source = evt.getSource();if (source = land | source = JPF) / 登陆按纽及第二个文本输入框ENTER功能实现String a = , b, read;boolean denglusuccees = false;try FileReader fr = new FileReader(denglu.txt);BufferedReader br = new BufferedReader(fr);while (read = br.readLine() != null) StringTokenizer sto = new StringTokenizer(read);a = sto.nextToken();b = sto.nextToken();if (jf1.getText().equals(a) & JPF.getText().equals(b) denglusuccees = true;break;/ 验证登陆员号码及密码 catch (IOException ie) System.err.println(ie.getMessage();if (denglusuccees = true) setVisible(false);mainview mw = new mainview();mw.setTitle(a + 为您服务);mw.setSize(850, 500);mw.setLocation(200, 180);mw.setVisible(true); else jf1.setText();JPF.setText();JOptionPane.showMessageDialog(null, 非法用户);private JLabel label1, label2, label3;private Box hbox1, hbox2, vbox;private JTextField jf1;private JPasswordField JPF;private JButton land;private JPanel panel1, panel2;物价计算public class draw double a;double b;String c;public draw(double fnum, double all, String information) / 构造函数a = fnum;/ 获得指定商品当销售额b = all;/ 获得当天总销售额c = information;/ 获得指定商品的编号DrawJDialog frame = new DrawJDialog();frame.setSize(400, 300);frame.setLocation(400, 300);frame.setVisible(true);class DrawJDialog extends JDialog implements ActionListener/ 界面及功能实现JButton shut;JTextArea one = new JTextArea();DrawPanel panel = new DrawPanel();shut = new JButton(关闭);shut.addActionListener(this);double rate = 100 * a / b;DecimalFormat df = new DecimalFormat(#.00);rate = Double.parseDouble(df.format(rate);/ 格式化小数显示one.setText( + c + n + 占今天销售额 + rate + %);panel.add(one);panel.add(shut);Container contentPane = getContentPane();contentPane.add(panel);setTitle(销售情况);public void actionPerformed(ActionEvent evt) Object source = evt.getSource();setVisible(false);class DrawPanel extends JPanel/ 画饼图public void paintComponent(Graphics g) g.clearRect(30, 40, 150, 150);double x1 = a;double x2 = b;int angle;super.paintComponent(g);angle = (int) (360 * x1 / x2);g.setColor(Color.blue);g.drawArc(30, 100, 150, 150, 0, angle);g.fillArc(30, 100, 150, 150, 0, angle);g.setColor(Color.GREEN);g.drawArc(30, 100, 150, 150, 0 + angle, 360 - angle);g.fillArc(30, 100, 150, 150, 0 + angle, 360 - angle);应用操作import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;import java.awt.*;import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.*;class mainview extends JFrame implements ActionListenerDataManagement mydata = new DataManagement();sellcount mysell = new sellcount();judge myjudge = new judge();int dcount = 1;public mainview() changeButton1 = new JButton(修改价格);changeButton1.addActionListener(this);changeButton1.setEnabled(false);changeButton2 = new JButton(修改数量);changeButton2.addActionListener(this);changeButton2.setEnabled(false);deleteButton = new JButton(删除商品);deleteButton.addActionListener(this);deleteButton.setEnabled(false);finishButton = new JButton(完成结算);finishButton.addActionListener(this);finishButton.setEnabled(false);cheapButton = new JButton(会员结算);cheapButton.addActionListener(this);cheapButton.setEnabled(false);recordButton = new JButton(记录清单);recordButton.addActionListener(this);recordButton.setEnabled(false);moneyButton = new JButton(找零计算);moneyButton.addActionListener(this);moneyButton.setEnabled(false);clearButton = new JButton(清除清单);clearButton.addActionListener(this);textAll = new JTextField(0);textAll.setEditable(false);textAll.setBorder(BorderFactory.createEtchedBorder();textChange = new JTextArea(7, 0);textChange.setEditable(false);textChange.setBorder(BorderFactory.createEtchedBorder();hbox2 = Box.createHorizontalBox();vbox2 = Box.createVerticalBox();vbox2.add(Box.createVerticalStrut(9);vbox2.add(changeButton1);vbox2.add(Box.createVerticalStrut(9);vbox2.add(changeButton2);vbox2.add(Box.createVerticalStrut(9);vbox2.add(deleteButton);vbox2.add(Box.createVerticalStrut(9);vbox2.add(finishButton);vbox2.add(Box.createVerticalStrut(9);vbox2.add(cheapButton);vbox2.add(Box.createVerticalStrut(9);vbox2.add(textAll);vbox2.add(moneyButton);vbox2.add(textChange);vbox2.setBorder(BorderFactory.createEtchedBorder();textArea = new JTextArea(24, 37);textArea.setMaximumSize(textArea.getPreferredSize();textArea.setEditable(false);scrollPane = new JScrollPane(textArea);textAdd = new JTextField(20);textAdd.addActionListener(this);vbox1 = Box.createVerticalBox();hbox1 = Box.createHorizontalBox();label1 = new JLabel(此处输入商品编号 );label2 = new JLabel(商品信息显示:);drawButton = new JButton(单天商品销售情况);drawButton.addActionListener(this);vbox1.add(label1);vbox1.add(textAdd);hbox1.add(label2);hbox1.add(drawButton);vbox1.add(hbox1);vbox1.add(scrollPane);vbox1.setBorder(BorderFactory.createLoweredBevelBorder();vbox3 = Box.createVerticalBox();hbox3 = Box.createHorizontalBox();label3 = new JLabel(最终清单);label4 = new JLabel(版权所属);label4.setBorder(BorderFactory.createEtchedBorder();textFinish = new JTextArea(24, 30);textFinish.setEditable(false);textFinish.setBorder(BorderFactory.createEtchedBorder(Color.WHITE,Color.BLACK);hbox3.add(recordButton);hbox3.add(Box.createHorizontalStrut(10);hbox3.add(clearButton);hbox3.add(Box.createHorizontalStrut(10);hbox3.add(label4);vbox3.add(new clock();vbox3.add(label3);hbox3.setBorder(BorderFactory.createEtchedBorder();vbox3.add(textFinish);vbox3.add(hbox3);vbox3.setBorder(BorderFactory.createLoweredBevelBorder();hbox2.add(vbox1);hbox2.add(vbox2);hbox2.add(vbox3);getContentPane().add(hbox2);addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0););public void actionPerformed(ActionEvent evt) Object source = evt.getSource();if (source = textAdd) / 商品添加String log = textAdd.getText();StringTokenizer sto = new StringTokenizer(log);String dcode = sto.nextToken();boolean inputwrite = true;int dnum = 1;if (sto.hasMoreTokens()try int tempnum=Integer.parseInt(sto.nextToken();if(tempnum0)dnum = Integer.parseInt(sto.nextToken();else inputwrite=false; catch (NumberFormatException e) JOptionPane.showMessageDialog(null, 请输入数字);inputwrite = false;if (inputwrite = true) if (myjudge.find(dcode) = -1) String wrong = Cant find + dcode;JOptionPane.showMessageDialog(null, wrong);textAdd.setText(); else int location = myjudge.find(dcode);String dname = myjudge.judgeDatalocation.getName();double dprice = myjudge.judgeDatalocation.getPrice();mydata.add(dcode, dname, dprice, dnum);textArea.setText();for (int i = 0; i mydata.acount; i+) textArea.insert(商品 + (i + 1) + 编号:+ ductDatai.getCode() + 商品名称:+ ductDatai.getName() + 商品价格: + ductDatai.getPrice() + 元/单位 + ductDatai.getNum() + 个 + n,0);textArea.insert( 共 + mydata.givecost() + 元n, 0);textAdd.setText();changeButton1.setEnabled(true);changeButton2.setEnabled(true);deleteButton.setEnabled(true);cheapButton.setEnabled(true);finishButton.setEnabled(true); else textAdd.setText();else if (source = drawButton) String ecode = JOptionPane.showInputDialog(null, 请输入欲查询的商品编号);if (ecode != null) if (mysell.find(ecode) = -1)JOptionPane.showMessageDialog(null, 今天还未出售 + ecode);elsenew draw(mysell.sellDatamysell.find(ecode).getNum()* mysell.sellDatamysell.find(ecode).getPrice(),mysell.givecost(), mysell.sellinformantion(mysell.find(ecode);else if (source = changeButton1) double tempprice;String changepricecode = JOptionPane.showInputDialog(输入要修改价格的商品编号);if (changepricecode != null) int getpchange = mydata.find(changepricecode);if (getpchange = -1)JOptionPane.showMessageDialog(null, 用户未购买货物+ changepricecode);else double price = ductDatagetpchange.getPrice();try tempprice = Double.parseDouble(JOptionPane.showInputDialog(输入新单价);while (tempprice = 0) tempprice = Double.parseDouble(JOptionPane.showInputDialog(重新输入新单价(系统默认大于零元));price=tempprice; catch (NumberFormatException e) JOptionPane.showMessageDialog(null, 请输入数字);ductDatagetpchange.setPrice(price);textArea.setText();for (int i = 0; i mydata.acount; i+) textArea.insert(商品 + (i + 1) + 编号:+ ductDatai.getCode() + 商品名称:+ ductDatai.getName() + 商品价格: + ductDatai.getPrice() + 元/单位 + ductDatai.getNum() + 个 + n,0);textArea.insert( 共 + mydata.givecost() + 元n, 0);else if (source = changeButton2) String changenum = JOptionPane.showInputDialog(输入要修改数量的商品编号);if (changenum != null) int getnchange = mydata.find(changenum);if (getnchange = -1)JOptionPane.showMessageDialog(null, 用户未购买货物 + changenum);else int num = ductDatagetnchange.getNum();try num = Integer.parseInt(JOptionPane.showInputDialog(输入新数量);while (num =0)ductDatagetnchange.setNum(num);textArea.setText();for (int i = 0; i mydata.acount; i+) textArea.insert(商品 + (i + 1) + 编号:+ ductDatai.getCode() + 商品名称:+ ductDatai.getName() + 商品价格: + ductDatai.getPrice() + 元/单位 + ductDatai.getNum() + 个 + n,0);textArea.insert( 共 + mydata.givecost() + 元n, 0);else if (source = deleteButton) String deletecode = JOptionPane.showInputDialog(输入所要删除货物的编号);if (deletecode != null) boolean getdelete = mydata.delete(deletecode);if (getdelete = false)JOptionPane.showMessageDialog(null, 用户未购买货物 + deletecode);else textArea.setText();for (int i = 0; i mydata.acount; i+) textArea.insert(商品 + (i + 1) + 编号:+ ductDatai.getCode() + 商品名称:+ ductDatai.getName() + 商品价格: + ductDatai.getPrice() + 元/单位 + ductDatai.getNum() + 个 + n,0);textArea.insert( 共 + mydata.givecost() + 元n, 0);else if (source = finishButton) int a = JOptionPane.showConfirmDialog(null, 确定后将不可再修改清单);if (a = JOptionPane.YES_OPTION) textArea.setText();textFinish.insert( 谢谢您的惠顾, 0);textFinish.insert( 共 + mydata.givecost() + 元n, 0);textFinish.insert(-+ n, 0);for (int i = 0; i mydata.acount; i+) textFinish.insert(商品 + (i + 1) + 编号:+ ductDatai.getCode() + 商品名称:+ ductDatai.getName() + 商品价格: + ductDatai.getPrice() + 元/单位 + ductDatai.getNum() + 个 + n, 0);textFinish.insert(-+ n, 0);textFinish.insert(软院小超市 + n, 0);textAll.setText(总价: + mydata.givecost();mysell.save(mydata);changeButton1.setEnabled(false);changeButton2.setEnabled(false);deleteButton.setEnabled(false);recordButton.setEnabled(true);moneyButton.setEnabled(true);cheapButton.setEnabled(false);finishButton.setEnabled(false);textAdd.setEnabled(false);recordButton.doClick();else if (source = cheapButton) String vipnumber = ;vipnumber = JOptionPane.showInputDialog(null, 请输入VIP用户会员号码);if (vipnumber != null) boolean vipsuccees = false;String read;try FileReader fr = new FileReader(vip.txt);BufferedReader br = new BufferedReader(fr);while (read = br.readLine() != null) if (vipnumber.equals(read) vipsuccees = true;break; catch (IOException ie) System.err.println(ie.getMessage();if (vipsuccees = true) int a = JOptionPane.showConfirmDialog(null, 确定后将不可再修改清单);if (a = JOptionPane.YES_OPTION) textArea.setText();textFinish.insert( VIP会员 + vipnumber + 优惠50%,只需 + mydata.givecost2() + 元, 0);textFinish.insert( 原价 + mydata.givecost() + 元n, 0);textFinish.insert(-+ n, 0);for (int i = 0; i mydata.acount; i+) textFinish.insert(商品 + (i + 1) + 编号:+ ductDatai.getCode()+ 商品名称:+ ductDatai.getName()+ 商品价格: + ductDatai.getPrice()+ 元/单位 + ductDatai.getNum()+ 个 + n, 0);textFinish.insert(-+ n, 0);textFinish.insert(软院小超市 + n, 0);textAll.setText(总价: + mydata.givecost2();mysell.save(mydata);changeButton1.setEnabled(false);changeButton2.setEnabled(false);deleteButton.setEnabled(false);recordButton.setEnabled(true);moneyButton.setEnabled(true);cheapButton.setEnabled(false);finishButton.setEnabled(false);textAdd.setEnabled(false);recordButton.doClick(); elseJOptionPane.showMessageDialog(null, 非VIP会员号码);else if (source = recordButton) mydata.record();JOptionPane.showMessageDialog(null, 交易信息记录成功);recordButton.setEnabled(false);else if (source = moneyButton) String clientmoney = JOptionPane.showInputDialog(用户给予金额);if (clientmoney != null) double inmoney = Double.parseDouble(clientmoney);String outmoney = mydata.moneycount(inmoney);textChange.setText(outmoney);moneyButton.setEnabled(false);
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 郑大远程c语言考试题及答案
- 跨国贸易三人合伙人进出口业务合作协议及结算条款
- 离婚协议中财产分割及子女抚养及监护权协议
- 离婚子女户口迁移抚养责任协议及监护权执行协议
- 离婚协议书模板:夫妻债务处理及责任分担细则
- 离婚协议书模板:包含赡养费与子女教育金的全面协议
- 离婚财产债务分割及子女教育保障协议示范
- 自来水改造及智能化建设工程方案
- 校园文明与安全教育
- 水库建设项目工程方案
- 未遂统计管理办法
- 经营性公墓建设-可行性研究报告
- 广东省事业单位公开招聘人员报名表
- 电厂消防系统培训课件
- 广东省广州市越秀区2024-2025学年七年级下学期期末考试英语试卷(含答案无听力音频及原文)
- 四不放过原则培训
- 执法办案培训课件
- 职业中介公司管理制度
- 儿童口腔预防保健知识
- 机扩根管治疗讲课件
- 中医护理知识试题及答案
评论
0/150
提交评论