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