資源簡介
java簡單的購物車 有清空、刪除、增加、修改等功能
代碼片段和文件信息
import?java.awt.*;
import?java.awt.event.*;
class?Shopframe?extends?frame?implements?ActionListener
{???Label?label1label2label3label4label5label6;
????Button?button1button2button3button4button5button6button7;
????TextArea?text;
????Panel?panel1panel2;
????static?float?sum=0.0f;
????Shopframe(String?s)
????{?super(s);
??????setLayout(new?BorderLayout());
??????label1=new?Label(“杯子:3元“Label.LEFT);
??????label2=new?Label(“鋼筆:5元“Label.LEFT);
??????label3=new?Label(“香皂:10元“Label.LEFT);
??????label4=new?Label(“襪子:8元“Label.LEFT);
??????label5=new?Label(“衛生紙:17元“Label.LEFT);
??????label6=new?Label(“布娃娃:30元“Label.LEFT);
??????button1=new?Button(“加入購物車“);
??????button2=new?Button(“加入購物車“);
??????button3=new?Button(“加入購物車“);
??????button4=new?Button(“加入購物車“);
??????button6=new?Button(“加入購物車“);
??????button7=new?Button(“加入購物車“);
??????button5=new?Button(“查看購物車里物品的總額“);
??????text=new?TextArea(“所買商品有:“+“\n“);
???
??????text.setEditable(false);
??????addWindowListener(new?WindowAdapter()
????????????????????????{??public?void?windowClosing(WindowEvent?e)
???????????????????????????{??System.exit(0);
???????????????????????????}
????????????????????????}
????????????????????????);
??????button1.addActionListener(this);
??????button2.addActionListener(this);
??????button3.addActionListener(this);
??????button4.addActionListener(this);
??????button6.addActionListener(this);
??????button7.addActionListener(this);
??????button5.addActionListener(this);
??????
??????panel1=new?Panel();
??????panel2=new?Panel();
??????panel1.
- 上一篇:JAVA學生教師信息錄入小系統
- 下一篇:JAVAEE圖書管理系統
評論
共有 條評論