java购物车系统代码_java购物车系统 团队博客

1. 团队名称、团队成员介绍(需要有照片)

团队名称:一颗LFL

团队成员:廖余俊 计算机工程学院网络工程1512 学号201521123053

方旭 计算机工程学院网络工程1512 学号201521123048

蓝锦明 计算机工程学院网络工程1512 学号201521123052.

照片

迷途小书童

7c6a024ea8a7187e7ceaaae7069f1a06.png

一只琳娜c

42597b8d61e0937afec37d1c173c51e1.png

岛歌

5983b90bced0c947d025b1ed84c7cd8b.png

2. 项目git地址

3. 项目git提交记录截图(要体现出每个人的提交记录、提交说明),老师将点击进去重点考核。

19b57e43627c4c034f958dbb5600e653.png

4. 项目功能架构图与主要功能流程图

5. 项目运行截图

首页

8e5dfa2db4cb62e4c50786d2717f8168.png

商品展示页面

7d1b713ee8b176db5cca64733c6bfb6e.png

成功添加至购物车

c2a21a356ad3ee721a7a22dc6389c689.png

5493e88db82a3d6b2b69743da1cfedda.png

删除商品

a4be40511d5183d8ef9c923b15fd93ff.png

修改商品

dc72bf20e188a46c0471bd9c731372de.png

最后显示

bc7b34acf8f791f601e2c0e8bee7d900.png

6. 项目关键代码(不能太多)

public class Item

{

private int no;

private String name;

private String brand;

private double price;

// -------------------------------------------------------

// Create a new item with the given attributes.

// -------------------------------------------------------

public name(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;

}

/**

* 获取价格

* @return

*/

public double getPrice()

{

return price;

}

/**

* 获取产品名称

* @return

*/

public String getName()

{

return name;

}

/**

* 获取品牌名称

* @return

*/

public String getBrand() {

return brand;

}

/**

* 获取商品编号

* @return

*/

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));

}

}

public class ShoppingCart

{

private int itemCount; // 商品数量

private double totalPrice; // 购物车总价格

private int capacity; // 数组大小

private Item[] cart;

// -----------------------------------------------------------

// Creates an empty shopping cart with a capacity of 5 items.

// -----------------------------------------------------------

public ShoppingCart()

{

capacity = 5;

itemCount = 0;

totalPrice = 0.0;

cart = new Item[capacity];

}

/**

*

* 添加功能

*/

public void buy(Item item)

{

if(itemCount == capacity){

increaseSize();

}

cart[itemCount] = item;

totalPrice += cart[itemCount].getPrice();

itemCount++;

return;

}

/**

* 删除功能

*/

public void deleteCart(int No) {

int i;

for (i = 0; i < cart.length; i++) {

if(cart[i].getNo() == No){

totalPrice -= cart[i].getPrice();

for (int j = i; j < cart.length-1; j++) {

cart[j] = cart[j+1];

}

itemCount--;

break;

}

}

if(i == cart.length){

System.out.println("无此商品,无法删除。");

}

return;

}

/**

* 修改功能

*/

public void updateCart(int No) {//修改编号

int i;

@SuppressWarnings("resource")

Scanner scan = new Scanner(System.in);

for (i = 0; i < cart.length; i++) {

if(cart[i].getNo() == No){

totalPrice -= cart[i].getPrice();

System.out.println("需要修改的信息如下:");

System.out.println(cart[i]);

System.out.println("请输入新的产品信息:");

cart[i].setNo(scan.nextInt());

cart[i].setName(scan.next());

cart[i].setBrand(scan.next());

cart[i].setPrice(scan.nextDouble());

totalPrice += cart[i].getPrice();

break;

}

}

if(i == cart.length){

System.out.println("无此商品");

}

return;

}

/**

* 增加购物车容量

*/

private void increaseSize()

{

Item[] temp = new Item[capacity + 3];

for (int i = 0; i < cart.length; i++) {

temp[i] = cart[i];

}

cart = temp;

}

/**

*获取商品总值

*/

public double getTotalPrice() {

return totalPrice;

}

public Item[] getCart() {

return cart;

}

public void setCart(Item[] cart) {

this.cart = cart;

}

/**

* 输出购物车信息

*/

public String toString()

{

String contents = "您的购物车信息如下:";

contents += "\nno\t\tname\t\tbrand\t\tprice\n";

for (int i = 0; i < itemCount; i++)

contents += cart[i].toString() + "\n";

return contents;

}

}

7. 尚待改进或者新的想法

浏览商品界面未对商品进行分类,商品的分类有利于用户更快查找到需要购买的商品

购买购物车中的商品时未进行支付方式的选择并支付,未实现支付功能

每个用户的购物车信息还未实现与用户一一对应

8. 团队成员任务分配,团队成员课程设计博客链接(以表格形式呈现),标明组长。

组员博客链接

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值