001 package videoautomat;
002 import sale.Shop;
003 import users.UserManager;
004 import data.Catalog;
005 import data.CatalogItem;
006 import data.CountingStock;
007 import data.IntegerValue;
008 import data.NumberValue;
009 import data.QuoteValue;
010 import data.ooimpl.CatalogItemImpl;
011 import data.ooimpl.EUROCurrencyImpl;
012 import data.ooimpl.MoneyBagImpl;
013
014 /**
015 * This class implements the start up of the whole application, it contains also the main void of
016 * this app.
017 *
018 */
019 public class MainClass {
020
021 /**
022 * Represents the cost per day for renting a video.
023 */
024 public static NumberValue RENT_VALUE_DAY = new IntegerValue(200);
025 /**
026 * The main void of the application, starts up the automat.
027 *
028 * @param arqs
029 * takes no effect
030 */
031
032 public static void main(String arqs[]) {
033 VideoShop shop = new VideoShop();
034 Shop.setTheShop(shop);
035 shop.start();
036 shop.addSalesPoint(new VideoAutomat());
037 initializeVideos();
038 initializeUsers();
039 initializeMoney();
040 }
041
042 /**
043 * Method to initial add some coins to the {@link VideoShop}s <code>MoneyBag</code>.
044 *
045 */
046 public static void initializeMoney() {
047 MoneyBagImpl mbi =
048 (MoneyBagImpl) Shop.getTheShop().getStock(VideoShop.MB_MONEY);
049 mbi.add(EUROCurrencyImpl.CENT_STCK_10, 100, null);
050 mbi.add(EUROCurrencyImpl.CENT_STCK_20, 100, null);
051 mbi.add(EUROCurrencyImpl.CENT_STCK_50, 100, null);
052 mbi.add(EUROCurrencyImpl.EURO_STCK_1, 100, null);
053 mbi.add(EUROCurrencyImpl.EURO_STCK_2, 50, null);
054 mbi.add(EUROCurrencyImpl.EURO_SCHEIN_10, 100, null);
055 mbi.add(EUROCurrencyImpl.EURO_SCHEIN_20, 10, null);
056 }
057 /**
058 * Method to initial add some videos to the {@link VideoShop}s <code>Stock</code>.
059 *
060 */
061 public static void initializeVideos() {
062
063 Catalog videoCatalog = VideoShop.getVideoCatalog();
064 CountingStock videoStock = VideoShop.getVideoStock();
065
066 for (int i = 0; i < 10; i++) {
067 String s = "Video-" + i;
068 CatalogItem video = new CatalogItemImpl(s,
069 new QuoteValue(new IntegerValue(1500),new IntegerValue(3000))) {
070 // implementation of the inherited abstract method
071 protected CatalogItemImpl getShallowClone() {
072 return null;
073 }
074 };
075
076 videoCatalog.add(video, null);
077 videoStock.add(s, 5, null);
078 }
079 }
080
081 /**
082 * Method to initial add some users to the global <code>UserManager</code>.
083 *
084 */
085 public static void initializeUsers() {
086 UserManager.getGlobalUM().addUser(new AutomatUser("Administrator", new char[0], true));
087 for (int i = 0; i < 10; i++) {
088 UserManager.getGlobalUM().addUser(
089 new AutomatUser("Customer" + i, new char[0], false));
090 }
091 }
092 }