1 7 package org.jboss.tutorial.stateful_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 HashMap <String , Integer > getCartContents() 31 { 32 return cart; 33 } 34 35 public void checkout() 36 { 37 System.out.println("To be implemented"); 38 } 39 } 40 | Popular Tags |