コード例 #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);

            BetsCollection collection1 = new BetsCollection();

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

            model.Bets = collection1;
            model.getAllActiveBets();

            BetsCollection collection2 = new BetsCollection();

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

            user1.Bets = collection2;
            user1.getAllActiveBets();

            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 BetsIterator(BetsCollection bets)
 {
     this._bets = bets;
 }