Пример #1
0
        static void Main(string[] args)
        {
            User model = retriveFirstUserFromDatabase();

            UserView view = new UserView();

            UserController controller = new UserController(model, view);

            controller.updateView();

            controller.setUserName("Valentyn");

            controller.updateView();

            User user1 = new User("Oleg", "*****@*****.**", 10008);

            PurchaseCollection collection1 = new PurchaseCollection();

            collection1[0] = new Purchase.Builder()
                             .withKind("Percent Bet")
                             .withName("Football")
                             .withTeam("Real Madrid")
                             .withDate(DateTime.Now)
                             .withAmount(2500)
                             .build();
            collection1[1] = new Purchase.Builder()
                             .withKind("Percent Bet")
                             .withName("Football")
                             .withTeam("Barcelona")
                             .withDate(DateTime.Now)
                             .withAmount(500)
                             .build();

            model.Purchases = collection1;
            model.getAllActivePurchases();

            PurchaseCollection collection2 = new PurchaseCollection();

            collection2[0] = new Purchase.Builder()
                             .withKind("Percent Bet")
                             .withName("Chess")
                             .withTeam("Kasparov`s team")
                             .withDate(DateTime.Now)
                             .withAmount(800)
                             .build();
            collection2[1] = new Purchase.Builder()
                             .withKind("Percent Bet")
                             .withName("Football")
                             .withTeam("Real Madrid")
                             .withDate(DateTime.Now)
                             .withAmount(2500)
                             .build();
            collection2[2] = new Purchase.Builder()
                             .withKind("Percent Bet")
                             .withName("Basketball")
                             .withTeam("Orlando")
                             .withDate(DateTime.Now)
                             .withAmount(1800)
                             .build();

            user1.Purchases = collection2;
            user1.getAllActivePurchases();

            model.sendMessage("Hi Ivan! It`s a nice day to make bets!");
            Thread.Sleep(2000);
            user1.sendMessage("Hello! Valentyn! I agree with you!");
            Thread.Sleep(1000);
            model.sendMessage("I made one on football...");
            Thread.Sleep(2000);
            user1.sendMessage("Nice! Good luck :D\n");

            UserCollection e = new UserCollection();

            e.Attach(model);
            e.Attach(user1);

            Console.WriteLine("Our site is giving the bonus to a total amount of cash on the balance...\n");
            e.Accept(new TotalCashVisitor());

            Console.ReadLine();
        }
Пример #2
0
 public PurchaseIterator(PurchaseCollection purchases)
 {
     this._purchases = purchases;
 }