Пример #1
0
        public virtual void Transfer(BaseAccount account, double sum)
        {
            if (Amount < sum)
            {
                return;
            }

            Withdraw(sum);
            account.Deposit(sum);

            Console.WriteLine("transfer complete " + Amount);
        }
Пример #2
0
 public Decorator(BaseAccount account, float?unverifiedLimit)
 {
     Account         = account;
     UnverifiedLimit = unverifiedLimit;
     if (account.C.Passport == null || account.C.Addy == "")
     {
         Verified = false;
     }
     else
     {
         Verified = true;
     }
 }
Пример #3
0
        public static void Main(string[] args)
        {
            ClientBuilder builder = new ClientBuilder();

            builder.AddName("John", "Green");
            //builder.AddAddress("CA");
            //builder.AddPassportNumber(111);
            Client client1 = builder.GetResult();

            Console.WriteLine(client1.ToString() + "\n");

            builder.Reset();
            builder.AddName("Angela", "Green");
            builder.AddAddress("NY");
            builder.AddPassportNumber(222);
            Client client2 = builder.GetResult();

            Console.WriteLine(client2.ToString() + "\n");


            BaseAccount acc1 = Factory.CreateAccount(interest: 0.04, client: client1);       // standard acc
            BaseAccount acc2 = Factory.CreateAccount(limit: 300, fee: 50, client: client2);  // credit acc
            BaseAccount acc3 = Factory.CreateAccount(day: 2, interest: 50, client: client2); // deposit acc

            acc2.Deposit(1000);
            acc2.Withdraw(305);
            acc1.Deposit(1000);
            acc3.Deposit(1000);
            acc3.Withdraw(500);
            acc1.Transfer(acc2, 50);

            BaseAccount unverifiedAccount = new Decorator(acc1, 1000);

            try
            {
                unverifiedAccount.Withdraw(1200);
                unverifiedAccount.Transfer(acc2, 500);
                //Console.WriteLine(unverifiedAccount.Client.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            var task1 = new SetInterestHandler();
            var task2 = new WithdrawHandler();

            task1.SetNext(task2);
            task1.Handle(acc1);
        }
Пример #4
0
 new public void Transfer(BaseAccount account, double money)
 {
     if (account != null)
     {
         if (!Verified && money > UnverifiedLimit)
         {
             throw new Exception("cant transfer");
         }
         else
         {
             Account.Transfer(Account, money);
             Console.WriteLine("success");
         }
     }
     else
     {
         throw new Exception("doesnt exist");
     }
 }