Java课程设计 购物车系统(个人博客) 201521123052 蓝锦明

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

课程设计团队博客

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

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

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

1109913-20170623111046820-55388010.png
1109913-20170623111120538-642247937.png

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 + "\t\t" + name + "\t\t" + brand + "\t\t" + 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. 课程设计感想

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

转载于:https://www.cnblogs.com/JML1225/p/7068656.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值