1 7 package org.jboss.tutorial.entity.client; 8 9 10 import org.jboss.tutorial.entity.bean.LineItem; 11 import org.jboss.tutorial.entity.bean.Order; 12 import org.jboss.tutorial.entity.bean.ShoppingCart; 13 14 import javax.naming.InitialContext ; 15 16 22 public class Client 23 { 24 public static void main(String [] args) throws Exception 25 { 26 InitialContext ctx = new InitialContext (); 27 ShoppingCart cart = (ShoppingCart) ctx.lookup(ShoppingCart.class.getName()); 28 29 System.out.println("Buying 2 memory sticks"); 30 cart.buy("Memory stick", 2, 500.00); 31 System.out.println("Buying a laptop"); 32 cart.buy("Laptop", 1, 2000.00); 33 34 System.out.println("Print cart:"); 35 Order order = cart.getOrder(); 36 System.out.println("Total: $" + order.getTotal()); 37 for (LineItem item : order.getLineItems()) 38 { 39 System.out.println(item.getQuantity() + " " + item.getProduct() + " " + item.getSubtotal()); 40 } 41 42 System.out.println("Checkout"); 43 cart.checkout(); 44 45 } 46 } 47 | Popular Tags |