使用javabean实现简易购物车
本程序主要实现根据顾客类型判断是否有优惠并且可以选择购买多件同一类型的商品并结算
(使用三个文本框代替三个checkbox并修改javabean相应部分)
共需要exercise1.jsp欢迎顾客页面,buy.jsp选择购买商品页面,pay.jsp根据顾客类型结账页面,
javabean页面 Buy.java
定义所需要的变量和set、get方法。
package mybean;
import java.io.Serializable;
public class Buy implements Serializable {
private String username;
private String vip;
private int Clothes=0;
private int Pants=0;
private int Shoes=0;
private String notice;
private int sum;
public Buy() {
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getVip() {
return vip;
}
public void setVip(String vip) {
this.vip = vip;
}
public int getClothes() {
return Clothes;
}
public void setClothes(int Clothes) {
this.Clothes = Clothes;
}
public int getPants() {
return Pants;
}
public void setPants(int Pants) {
this.Pants = Pants;
}
public int getShoes() {
return Shoes;
}
public void setShoes(int Shoes) {
this.Shoes = Shoes;
}
public String getNotice() {
return notice;
}
public void setNotice(String notice) {
this.notice = notice;
}
public int getSum() {
return sum;
}
public void setSum(int sum) {
this.sum = sum;
}
public String PrintVip(){
if(vip.equals("y")) return "VIP";
else return "普通会员";
}