1 27 package olstore.form; 28 29 import java.util.ArrayList; 30 import java.math.BigDecimal; 31 32 import olstore.dto.ShoppingCartItem; 33 34 public class CheckoutForm extends DemoBaseForm { 35 36 private BigDecimal totalCost = new BigDecimal(0.00f); 37 private int numItems = 0; 38 private String submitType = null; 39 private ArrayList cartEntries = new ArrayList() ; 40 41 42 public BigDecimal getTotalCost () { 43 return totalCost; 44 } 45 46 public void setTotalCost ( BigDecimal cost ) { 47 totalCost = cost; 48 } 49 50 public int getNumItems () { 51 return numItems; 52 } 53 54 public void setNumItems ( int num ) { 55 numItems = num; 56 } 57 58 public String getSubmitType () { 61 return submitType; 62 } 63 64 public void setSubmitType ( String submit ) { 65 this.submitType = submit; 66 } 67 68 75 public ShoppingCartItem getCartItem (int index) { 76 if ( index >= cartEntries.size() ) { 77 int size = cartEntries.size(); 78 for ( int i =0; i < (index-size) + 1 ; i++ ) { 79 cartEntries.add ( new ShoppingCartItem() ); 80 } 81 } 82 return (ShoppingCartItem) cartEntries.get ( index ); 83 } 84 85 public void setCartItem ( int index, ShoppingCartItem item ) { 86 numItems++; 87 cartEntries.set ( index, item ); 88 } 89 90 public void reset(){ 91 totalCost = new BigDecimal(0.00f); 92 numItems = 0; 93 submitType = null; 94 cartEntries.clear(); 95 } 96 97 100 public ArrayList getCartEntries( ) { 101 return cartEntries; 102 } 103 104 public void setCartEntries ( ArrayList cartEntries ) { 105 this.cartEntries = cartEntries; 106 setNumItems(cartEntries.size()); 107 } 108 109 110 } 111 | Popular Tags |