东北石油大学本科生毕业设计(论文)
5.2 系统前台模块实现
图5-1 网上订餐系统主页
5.2.1 用户登录
主界面的左侧为用户登录区:登录/注册/注册模块,会员登录到会员的订餐空间,或者新用户注册。会员登录成功跳到个人订餐页面,失败则重置,管理员登录成功跳到后台管理,注册则跳右侧页面跳到注册页面,注销则是用户登录后注销登录所有信息。
23
东北石油大学本科生毕业设计(论文)
5.2.2 用户注册
图5-2 注册页面
进入到注册页面,就可以进行注册了,用户名必须是合法的输入,密码和确认密码必须一致,否则系统提示错误。
5.2.3 用户订餐
图5-3 用户订餐页面
24
东北石油大学本科生毕业设计(论文)
用户登录过后便可以订餐,每个菜都有其详细介绍,点击订购,就把该菜放入购物车中,点击详情就可以查看菜的详情。
5.2.4 购物车
图5-4 购物车图
点击订购物品就会进入购物车中,在购物车中可以对物品进行删除,清空,结账等操作以及菜品数量,价格统计。我是用javaBean创建购物车对象,其中编写方法来实现对购物车的功能。购物车实现代码如下:
package com.endity; import java.util.*; public class ShopCart {
private int totalCount; private Map map; public ShopCart() { }
//向购物车中加入食品信息 public void addFood(FoodInfo food)
totalCount=0; map=new HashMap();
25
东北石油大学本科生毕业设计(论文)
{
ShopCartItemitem=(ShopCartItem)map.get(new Integer(food.getFoodId())); }
//向购物车中删除某个食品信息 public void removeFood(int foodId) { }
public int getTotalCount() { }
//计算购物车中菜品总价格 public float getTotalPrice() {
Collection col=map.values(); float totalPrice=0; Iterator it=col.iterator(); while(it.hasNext()) {
ShopCartItem item=(ShopCartItem)it.next(); return totalCount;
ShopCartItem item=(ShopCartItem)map.get(new Integer(foodId)); item.delFoodCount(); if(item.getCount()<=0) { }
totalCount--;
map.remove(new Integer(foodId)); if(item == null) { } else { }
totalCount++;
item.addFoodCount();
map.put(new Integer(food.getFoodId()), new ShopCartItem(food));
26
东北石油大学本科生毕业设计(论文)
}
}
}
FoodInfo food=item.getFood();
totalPrice+=food.getFoodPrice()*item.getCount();
return totalPrice;
public Collection getAllFood() { }
//清空购物车中所有菜品 public void clearCart() { }
map.clear(); totalCount=0; return map.values();
5.2.5 订单
图5-5 订单
当订餐结束,选择购物车的结账,就可以跳转到订单界面。上面有订餐人的详细信息,生成订单。
27