001 package videoautomat; 002 003 import sale.Gate; 004 import sale.SaleProcess; 005 import sale.SalesPoint; 006 import sale.UIGate; 007 import videoautomat.contentcreator.HandBackSTFSContentCreator; 008 import videoautomat.contentcreator.HandBackTTFSContentCreator; 009 import data.IntegerValue; 010 import data.MoneyBag; 011 import data.NumberValue; 012 import data.ooimpl.CatalogItemImpl; 013 import data.ooimpl.MoneyBagImpl; 014 import data.ooimpl.StockItemImpl; 015 import data.ooimpl.StoringStockImpl; 016 import data.stdforms.SingleTableFormSheet; 017 import data.stdforms.TwoTableFormSheet; 018 import data.stdforms.twotableformsheet.SSSSStrategy; 019 020 /** 021 * This class implements a <code>SaleProcess</code> to hand back the videos. 022 * @author Alexander Herrmann 023 */ 024 public class SaleProcessHandBack extends SaleProcess { 025 026 /** 027 * ID for Serialization. 028 */ 029 private static final long serialVersionUID = -3003924365730438200L; 030 031 /** 032 * StoringStock to store temporary videos 033 */ 034 private StoringStockImpl<StockItemImpl, CatalogItemImpl> temporaryVideosStoringStock; 035 036 /** 037 * MoneyBag to temporarily store the change money 038 */ 039 private MoneyBag temporaryChangeMoneyBag; 040 041 /** 042 * NumberValue representing the change money 043 */ 044 private NumberValue changeMoneyNumberValue; 045 046 /** 047 * Constructs a new <code>SaleProcessHandBack</code> 048 * 049 */ 050 public SaleProcessHandBack() { 051 super("SaleProcessGiveback"); 052 } 053 054 /** 055 * Implementation of the inherited abstract method. 056 * 057 * @return the <code>Gate</code> where the user will see his/her current rented videos. 058 * @see sale.SaleProcess#getInitialGate() 059 * @author Alexander Herrmann 060 */ 061 protected Gate getInitialGate() { 062 063 // generate Gate 064 UIGate uig_video = new UIGate(null, null); 065 066 setTemporaryVideosStoringStock(new StoringStockImpl<StockItemImpl, CatalogItemImpl>("temp", VideoShop.getVideoCatalog())); 067 setTemporaryChangeMoneyBag(new MoneyBagImpl("temp", VideoShop.getCurrency())); 068 setChangeMoneyNumberValue(new IntegerValue(0)); 069 070 TwoTableFormSheet ttfs_handback = 071 TwoTableFormSheet.create( 072 "Give back a video", 073 ((AutomatUser) ((SalesPoint) this.getContext()).getUser()).getVideoStock(), 074 getTemporaryVideosStoringStock(), 075 getBasket(), 076 uig_video, 077 null, 078 null, 079 new TEDVideoCassette(), 080 new TEDVideoCassette(), 081 new SSSSStrategy(), 082 TwoTableFormSheet.RIGHT 083 ); 084 085 ttfs_handback.addContentCreator(new HandBackTTFSContentCreator()); 086 087 return uig_video; 088 } 089 090 /** 091 * Returns the initial Gate. 092 * 093 * @return initialGate 094 */ 095 public Gate restart() 096 { 097 return getInitialGate(); 098 } 099 100 /** 101 * @return the <code>Gate</code> where the user will see his/her change money. 102 * @author Alexander Herrmann 103 */ 104 public Gate getChangeGate() { 105 106 // generate Gate 107 UIGate uig_change = new UIGate(null, null); 108 109 SingleTableFormSheet stfs_change = 110 SingleTableFormSheet.create( 111 "Here is your change!", 112 getTemporaryChangeMoneyBag(), 113 uig_change, 114 getBasket()); 115 116 stfs_change.addContentCreator(new HandBackSTFSContentCreator(getChangeMoneyNumberValue())); 117 118 return uig_change; 119 } 120 121 /** 122 * Get the StoringStock to store temporary videos. 123 * @return the StoringStock to store temporary videos 124 */ 125 public StoringStockImpl<StockItemImpl, CatalogItemImpl> getTemporaryVideosStoringStock() { 126 return temporaryVideosStoringStock; 127 } 128 129 /** 130 * Set the StoringStock to store temporary videos. 131 * @param temporaryVideosStoringStock the StoringStock to store temporary videos 132 */ 133 public void setTemporaryVideosStoringStock(StoringStockImpl<StockItemImpl, CatalogItemImpl> temporaryVideosStoringStock) { 134 this.temporaryVideosStoringStock = temporaryVideosStoringStock; 135 } 136 137 /** 138 * Get the MoneyBag to temporarily store the change money. 139 * @return the MoneyBag to temporarily store the change money 140 */ 141 public MoneyBag getTemporaryChangeMoneyBag() { 142 return temporaryChangeMoneyBag; 143 } 144 145 /** 146 * Set the MoneyBag to temporarily store the change money. 147 * @param temporaryChangeMoneyBag the MoneyBag to temporarily store the change money 148 */ 149 public void setTemporaryChangeMoneyBag(MoneyBag temporaryChangeMoneyBag) { 150 this.temporaryChangeMoneyBag = temporaryChangeMoneyBag; 151 } 152 153 /** 154 * Get the NumberValue representing the change money. 155 * @return the NumberValue representing the change money 156 */ 157 public NumberValue getChangeMoneyNumberValue() { 158 return changeMoneyNumberValue; 159 } 160 161 /** 162 * Set the NumberValue representing the change money. 163 * @param changeMoneyNumberValue the NumberValue representing the change money 164 */ 165 public void setChangeMoneyNumberValue(NumberValue changeMoneyNumberValue) { 166 this.changeMoneyNumberValue = changeMoneyNumberValue; 167 } 168 169 }