java-超市收银系统_第1页
java-超市收银系统_第2页
java-超市收银系统_第3页
java-超市收银系统_第4页
java-超市收银系统_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、精品package software; import java.awt.*;import java.awt.event.*;import javax.swing.*;class shangpinString SId;String Smane;int jiage;public shangpin(String a,String b,int c)SId=a;Smane=b;jiage=c;class huiyuanString HId;String Hname;public huiyuan(String a,String b)HId=a;Hname=b;public class chaoshi ex

2、tends JFramestatic int key=0; / 会员static int sum1=0;/总消费static int sum2=0;/当天合计static int huiyuansum=0; / 会员人数static int Spinsum1=0; /商品1合计static int Spinsum2=0; /商品2合计static int Spinsum3=0; /商品3合计static int Spinsum4=0; /商品4合计static int Spinsum5=0; /商品5合计public static void main(String agrs)JFrame fr

3、ame =new JFrame( 超市 );frame.setSize(400,250);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);Container c=frame.getContentPane();c.add(pan();frame.setVisible(true);static JPanel pan ()JPanel panel=new JPanel();JPanel part1=new JPanel();part1.add(new JLabel( 会员卡号:);final JTextField text1=new JTex

4、tField();text1.setHorizontalAlignment(JTextField.RIGHT);text1.setColumns(11);JButton button1=new JButton( 确定 );part1.add(text1); part1.add(button1);part1.setVisible(true);final JLabel JLabel00 =new JLabel( 非会员 );part1.add(JLabel00); panel.add(part1);JPanel part2=new JPanel();part2.add(new JLabel( 商品

5、代号:);final JTextField text2=new JTextField();text2.setHorizontalAlignment(JTextField.RIGHT);text2.setColumns(15);JButton button2=new JButton( 确定 );part2.add(text2); part2.add(button2);panel.add(part2);JPanel part3=new JPanel();final JLabel JLabel0=new JLabel();final JLabel JLabel1=new JLabel(000);fi

6、nal JLabel JLabel2=new JLabel(0000);part3.add(new JLabel(part3.add(new JLabel(商品名 ); part3.add(JLabel0);商品价格); part3.add(JLabel1);part3.add(new JLabel( 元 );part3.add(new JLabel(总价格 ); part3.add(JLabel2);- 可编辑 -part3.add(new JLabel( 元 );part3.add(new JLabel(); panel.add(part3);JPanel part4=new JPanel

7、();JButton button3=new JButton(结账 );JButton button4=new JButton(总汇 ); part4.add(button3););part4.add(new JLabel( part4.add(button4); panel.add(part4);button1.addActionListener(new ActionListener()huiyuan huiyuan1=new huiyuan(00001,会员甲);huiyuan huiyuan2=new huiyuan(00002,会员乙);huiyuan huiyuan3=new hui

8、yuan(00003,会员丙);public void actionPerformed(ActionEvent e)String kahao=text1.getText();if(kahao.equals(huiyuan1.HId)JLabel00.setText(huiyuan1.Hname); key=1;if(kahao.equals(huiyuan2.HId)JLabel00.setText(huiyuan2.Hname); key=1;if(kahao.equals(huiyuan3.HId)JLabel00.setText(huiyuan3.Hname); key=1;);butt

9、on2.addActionListener(new ActionListener()shangpin shangpin1=new shangpin(001,商品1,10);shangpin shangpin2=new shangpin(002,商品2,11);shangpin shangpin3=new shangpin(003,商品3,12);shangpin shangpin4=new shangpin(004,商品4,13);shangpin shangpin5=new shangpin(005,商品5,14);public void actionPerformed(ActionEven

10、t e)String shangpinhao=text2.getText();if(shangpinhao.equals(shangpin1.SId) JLabel0.setText( +shangpin1.Smane);String str = String.format(%04d,shangpin1.jiage);JLabel1.setText(str);sum1=sum1+shangpin1.jiage;sum2=sum2+shangpin1.jiage;String str1 = String.format(%04d,sum1);JLabel2.setText(str1); Spins

11、um1+;if(shangpinhao.equals(shangpin2.SId) JLabel0.setText( +shangpin2.Smane);String str = String.format(%04d,shangpin2.jiage);JLabel1.setText(str);sum1=sum1+shangpin2.jiage;sum2=sum2+shangpin2.jiage;String str1 = String.format(%04d,sum1);JLabel2.setText(str1); Spinsum2+;if(shangpinhao.equals(shangpi

12、n3.SId) JLabel0.setText( +shangpin3.Smane);String str = String.format(%04d,shangpin3.jiage);JLabel1.setText(str);sum1=sum1+shangpin3.jiage;sum2=sum2+shangpin3.jiage;String str1 = String.format(%04d,sum1);JLabel2.setText(str1); Spinsum3+;if(shangpinhao.equals(shangpin4.SId) JLabel0.setText( +shangpin

13、4.Smane);String str = String.format(%04d,shangpin4.jiage);JLabel1.setText(str);sum1=sum1+shangpin4.jiage;sum2=sum2+shangpin4.jiage;String str1 = String.format(%04d,sum1);JLabel2.setText(str1); Spinsum4+;if(shangpinhao.equals(shangpin5.SId) JLabel0.setText( +shangpin5.Smane);String str = String.forma

14、t(%04d,shangpin5.jiage);JLabel1.setText(str);sum1=sum1+shangpin5.jiage;sum2=sum2+shangpin5.jiage;String str1 = String.format(%04d,sum1);JLabel2.setText(str1); Spinsum5+;);button3.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)if(sum1!=0) huiyuansum+;JDialog duox=new

15、JDialog(); JPanel duoxP=new JPanel();duox.getContentPane().add(duoxP);duox.setTitle( 消费总额); duoxP .setVisible(true);duoxP .setLayout(new GridLayout(4,1,0,0);duox.setSize(200,300); duox.setVisible(true);JPanel panel1=new JPanel(); JPanel part11=new JPanel();JPanel part12=new JPanel();String str1 = St

16、ring.format(%04d,sum1);JLabel Label11=new JLabel(str1); Label11.setText(str1);part11.add(new JLabel( 消费总额:);part11.add(Label11);if(key!=1)&sum1=200) part12.add(new JLabel( 消费达 200 元发放一张会员卡);panel1.add(part12);panel1.add(part11); duoxP.add(panel1);key=0; sum1=0;JLabel0.setText(); JLabel1.setText(000)

17、;JLabel2.setText(0000); JLabel00.setText( 非会员 );text1.setText(); text2.setText(););button4.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)JDialog duox=new JDialog(); JPanel duoxP=newJPanel();duox.getContentPane().add(duoxP); duox.setTitle( 消 费总额 );duoxP .setVisible(t

18、rue);duoxP .setLayout(new GridLayout(8,1,0,0);duox.setSize(200,400); duox.setVisible(true);JPanel part21=new JPanel();JPanel part22=new JPanel();JPanel part23=new JPanel();JPanel part24=new JPanel();JPanel part25=new JPanel();JPanel part26=new JPanel();JPanel part27=new JPanel();JButton button5=new

19、JButton( 全部清零);final JLabel label21=new JLabel();part21.add(new JLabel( 总消费额);String str21 = String.format(%04d,sum2);label21.setText(str21); part21.add(label21);final JLabel label22=new JLabel();part22.add(new JLabel( 商品 1 消费量 );String str22 = String.format(%04d,Spinsum1);label22.setText(str22); pa

20、rt22.add(label22);final JLabel label23=new JLabel();part23.add(new JLabel( 商品 2 消费量 );String str23 = String.format(%04d,Spinsum2);label23.setText(str23); part23.add(label23);final JLabel label24=new JLabel();part24.add(new JLabel( 商品 3 消费量 );String str24 = String.format(%04d,Spinsum3);label24.setText(str24); part24.add(label24);final JLabel label25=new JLabel();part25 add(new JLabel( 商品 4 消费量 );String str25 = String.format(%04d,Spinsum4);label25.setText(str25); part25.add(label25);final JLabel label26=new JLabel();part26 add(new JLabel( 商品 5 消费量 );String str26 = String.format(%04d,Spi

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论