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                    for (int i = 0; i < 10; i++) { 
060                            String s = "Video-" + i;
061                            VideoShop
062                                    .getVideoCatalog()
063                                    .add(new CatalogItemImpl(
064                                            s,
065                                            new QuoteValue(
066                                                    new IntegerValue(1500),
067                                                    new IntegerValue(3000))) {
068                                    // implementation of the inherited abstract method
069                                    protected CatalogItemImpl getShallowClone() {
070                                            return null;
071                                    }
072                            }, null);
073                            VideoShop.getVideoStock().add(s, 5, null);
074                    }
075            }
076    
077            /**
078             * Method to initial add some users to the global <code>UserManager</code>.
079             *  
080             */
081            public static void initializeUsers() {
082                    UserManager.getGlobalUM().addUser(new AutomatUser("Administrator", new char[0], true));
083                    for (int i = 0; i < 10; i++) {
084                            UserManager.getGlobalUM().addUser(
085                                    new AutomatUser("Customer" + i, new char[0], false));
086                    }
087            }
088    }