Path of my class file is :C:\Tomcat\webapps\classes\shop
well one more thing i want to tell you , while compiling my ShoppingBasket.java file I am getting warning as :
Note: ShoppingBasket.java uses uncheked or unsafe operations.
Note:Recompile with -Xlint:unchecked for details.
thats why now i think i must show you my code of ShoppingBasket as:
package shop;
import java.io.*;
import java.util.*;
public class ShoppingBasket
{
Vector products;
public ShoppingBasket() {products = new Vector(); }
public void addProduct(Product product) throws Exception
{
boolean flag = false;
for(Enumeration enu=getProducts();enu.hasMoreElements()
{
Product item=(Product)enu.nextElement();
if(item.getId().equals(product.id))
{
flag = true;
item.quantity++;
break;
}
}
if(!flag){products.addElement(product);}
}
public void deleteProduct(
String str)
{
for(Enumeration enu =getProducts(); enu.hasMoreElements()
{
Product item = (Product)enu.nextElement();
if(item.getId().equals(str))
{
products.removeElement(item);
break;
}
}
}
public void emptyBasket() { products= new Vector(); }
public int getProductNumber() { return products.size(); }
public Enumeration getProducts(){ return products.elements(); }
public double getTotal()
{
Enumeration enu = getProducts();
double total;
Product item;
for(total=0.00;enu.hasMoreElements();total+=item.getTotal())
{
item = (Product) enu.nextElement();
}
return total;
}
}
I think due to the use of enumeration i am getting promblems
What is you opinion?