资源简介

我写的小示例供大家学习jsp之用!希望对大家的所帮助---dragonzhao

资源截图

代码片段和文件信息

package com.dragonzhao;

import java.util.*;
import java.io.*;
public class BuyCarBean {
  Hashtable myGoods=new Hashtable();
  
  public void addGoods(String Goods_idint Goods_Count)
   { //把商品加入购物车
    if(myGoods.containsKey(Goods_id))
    {//购物车中存在此商品则累加个数
      int Temp_Count=((Integer)myGoods.get(Goods_id)).intValue();
      Temp_Count=Temp_Count+Goods_Count;
      myGoods.put(Goods_idnew Integer(Temp_Count));
    }
    else
    {//购物车中不存在此商品
      myGoods.put(Goods_idnew Integer(Goods_Count));
     }
   }
   public boolean minusGoods(String Goods_idint Goods_Count)
   { //把商品从购物车中拿出
    if(myGoods.containsKey(Goods_id))
    {//购物车中存在此商品则减少个数
      int Temp_Count=((Integer)myGoods.get(Goods_id)).intValue();
      Temp_Count=Temp_Count-Goods_Count;
      if(Temp_Count<=0)
        deleteGoods(Goods_id);
      else
        myGoods.put(Goods_idnew Integer(Temp_Count));
      return true;
    }
    else
    {//购物车中不存在此商品
      return false;
     }
   }
  public Hashtable listMyGoods()
   {//得到购物车中所有商品
     return myGoods;
   }
  public boolean deleteGoods(String Goods_id)
   {//从购物车中删除一件商品
     if(myGoods.remove(Goods_id)==null)
       return false;
     else
       return true;
   }
/**
 * @param args
 */
public static void main(String[] args) {
// TODO Auto-generated method stub

}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     目录          0  2008-07-06 23:17  购物车

     目录          0  2008-04-22 10:16  购物车\ShoppingCar

     文件        465  2008-04-22 10:16  购物车\ShoppingCar\.classpath

     目录          0  2008-04-22 10:16  购物车\ShoppingCar\.myeclipse

     文件        306  2008-04-24 17:00  购物车\ShoppingCar\.mymetadata

     文件       1229  2008-04-24 17:00  购物车\ShoppingCar\.project

     目录          0  2008-04-22 10:17  购物车\ShoppingCar\src

     目录          0  2008-04-22 10:17  购物车\ShoppingCar\src\com

     目录          0  2008-04-22 10:17  购物车\ShoppingCar\src\com\dragonzhao

     文件       1507  2008-04-22 10:23  购物车\ShoppingCar\src\com\dragonzhao\BuyCarBean.java

     目录          0  2008-04-24 17:00  购物车\ShoppingCar\WebRoot

     文件       1357  2008-04-22 11:52  购物车\ShoppingCar\WebRoot\AddGoodsJsp.jsp

     文件       5037  2008-04-22 12:06  购物车\ShoppingCar\WebRoot\BuyBookJsp.jsp

     文件       1334  2008-04-22 11:55  购物车\ShoppingCar\WebRoot\DeleteGoodsJsp.jsp

     文件       2262  2008-04-22 12:08  购物车\ShoppingCar\WebRoot\FirstPageJsp.jsp

     目录          0  2008-04-22 10:16  购物车\ShoppingCar\WebRoot\meta-INF

     文件         39  2008-04-22 10:16  购物车\ShoppingCar\WebRoot\meta-INF\MANIFEST.MF

     文件       1369  2008-04-22 11:57  购物车\ShoppingCar\WebRoot\MinusJsp.jsp

     目录          0  2008-04-22 12:01  购物车\ShoppingCar\WebRoot\WEB-INF

     目录          0  2008-04-24 17:00  购物车\ShoppingCar\WebRoot\WEB-INF\classes

     目录          0  2008-04-24 17:00  购物车\ShoppingCar\WebRoot\WEB-INF\classes\com

     目录          0  2008-04-24 17:00  购物车\ShoppingCar\WebRoot\WEB-INF\classes\com\dragonzhao

     文件       1548  2008-04-24 17:00  购物车\ShoppingCar\WebRoot\WEB-INF\classes\com\dragonzhao\BuyCarBean.class

     目录          0  2008-04-22 10:16  购物车\ShoppingCar\WebRoot\WEB-INF\lib

     文件        388  2008-04-22 12:03  购物车\ShoppingCar\WebRoot\WEB-INF\web.xml

     目录          0  2008-07-06 23:17  购物车\上课前需要导入的数据库

     文件    1048576  2006-12-06 15:59  购物车\上课前需要导入的数据库\testDB_Data.MDF

     文件    1048576  2006-12-06 15:59  购物车\上课前需要导入的数据库\testDB_Log.LDF

----------- ---------  ---------- -----  ----

              2113993                    28

............此处省略1个文件信息

评论

共有 条评论