1 7 package org.jboss.tutorial.jboss_deployment_descriptor.bean; 8 9 import java.io.Serializable ; 10 import java.util.HashMap ; 11 12 public class ShoppingCartBean implements ShoppingCart, Serializable 13 { 14 private HashMap <String , Integer > cart = new HashMap <String , Integer >(); 15 16 public void buy(String product, int quantity) 17 { 18 if (cart.containsKey(product)) 19 { 20 int currq = cart.get(product); 21 currq += quantity; 22 cart.put(product, currq); 23 } 24 else 25 { 26 cart.put(product, quantity); 27 } 28 } 29 30 public void priceCheck(String product) 31 { 32 } 34 35 public HashMap <String , Integer > getCartContents() 36 { 37 return cart; 38 } 39 40 public void checkout() 41 { 42 System.out.println("To be implemented"); 43 } 44 } 45 | Popular Tags |