zoukankan      html  css  js  c++  java
  • Java课程设计 购物车系统(个人博客) 201521123052 蓝锦明

    1. 团队课程设计博客链接

    课程设计团队博客

    2. 个人负责模块或任务说明

    (1)制作图形菜单引导界面
    (2)定义各获取和输出类函数

    3. 自己的代码提交记录截图


    4. 自己负责模块或任务详细说明

    import java.text.NumberFormat; 
    
    public class Item 
    { 
    	private int no;
    	private String name; 
    	private String brand; 
    	private double price; 
    
    	// ------------------------------------------------------- 
    	//  Create a new item with the given attributes. 
    	// ------------------------------------------------------- 
    
    	public Item(int no, String name, String brand, double price) {
    		this.no = no;
    		this.name = name;
    		this.brand = brand;
    		this.price = price;
    	}
    	
    	public void setNo(int no) {
    		this.no = no;
    	}
    
    	public void setName(String name) {
    		this.name = name;
    	}
    
    	public void setBrand(String brand) {
    		this.brand = brand;
    	}
    
    	public void setPrice(double price) {
    		this.price = price;
    	}
    
    	public double getPrice() 
    	{ 
    		return price; 
    	} 
    
    	public String getName() 
    	{ 
    		return name; 
    	} 
    
    	public String getBrand() {
    		return brand;
    	}
    
    	public int getNo() {
    		return no;
    	}
    
    	public String toString () 
    	{ 
    		NumberFormat fmt = NumberFormat.getCurrencyInstance(); 
    
    		return (no + "		" + name + "		" + brand + "		" + fmt.format(price));
    	} 
    
    }  
    
    import java.awt.*;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.util.Scanner;
    
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    
    @SuppressWarnings("serial")
    public class ItemPanel extends JPanel{
    	private final int MAXNUM = 100;
    	private JLabel[] item;
    	private JLabel[] options;
    	private Scanner scanItems;
    	int num = 0;
    	
    	
    	public ItemPanel() throws FileNotFoundException {
    		scanItems = new Scanner(new File("E:\Eclipse\project\JAVA\src\item2\Items"));
    		
    		item = new JLabel[MAXNUM];
    		for (int i = 0; scanItems.hasNextLine(); i++) {
    			item[i] = new JLabel(scanItems.nextLine());
    			num++;
    		}
    		
    		options = new JLabel[5];
    		setLayout(new GridLayout(num + options.length, 1));
    		
                    options[0] = new JLabel("查看商品请输入1");
    		options[1] = new JLabel("购买商品请输入2");
    		options[2] = new JLabel("删除商品请输入3");
    		options[3] = new JLabel("修改商品请输入4");
    		options[4] = new JLabel("结算商品请输入0");
    	
    		for (int i = 0; i < num; i++) {
    			add(item[i]);
    		}
    		for (int i = 0; i < options.length; i++) {
    			add(options[i]);
    		}
    		setBackground(Color.white);
    		setPreferredSize(new Dimension(200,200
    				));
    	}
    }
    

    5. 课程设计感想

    本次设计实现了简单的购物车功能,设计这一整体项目的过程中,培养了我们综合能力和从全局考虑的思想。出于自己水平有限,也留下了很多待解决的问题,项目中还有不足之处等待完善。通过这次课程设计,锻炼了动手操作能力。更重要的是,培养了认真钻研,刻苦学习的精神。

  • 相关阅读:
    Android平台Qt开发入门教程 狼人:
    PySide教程:第一个PySide应用 狼人:
    MeeGo系统1.2版本新组件 狼人:
    讨论:.NET 4各项技术的应用前景,徐汇区网站设计 狼人:
    为 NokiaQt SDK增加新的Symbian SDK开发平台 狼人:
    Skia引擎API整理介绍(skia in Android 2.3 trunk) 狼人:
    Windows Phone 7 开发之:工具栏 狼人:
    Google Adsense(Google网站联盟)广告申请指南 狼人:
    PySide教程:一个简单的点击按钮示例 狼人:
    内部类类4线程两加两减
  • 原文地址:https://www.cnblogs.com/JML1225/p/7068656.html
Copyright © 2011-2022 走看看