示例#1
0
文件: InterBank.cs 项目: lukeses/bank
        public void SendBackInterBankTransfer(InterBankTransfer interBankTransfer)
        {
            var returnTransfer = new InterBankTransfer(interBankTransfer.getReceiverBank(), interBankTransfer.getReceiverID(),
                                                       interBankTransfer.getSenderBank(), interBankTransfer.getSenderID(), interBankTransfer.getAmount());

            SendInterBankTransfer(returnTransfer);
        }
示例#2
0
文件: Bank.cs 项目: lukeses/bank
        public void sendInterBankTransfer(InterBankTransfer interBankTransfer)
        {
            var senderAccount = this.AccountList.Find(b => b.ID == interBankTransfer.getSenderID());

            senderAccount.Withdraw(interBankTransfer.getAmount());
            InterBankOfBank.SendInterBankTransfer(interBankTransfer);
        }
示例#3
0
文件: InterBank.cs 项目: lukeses/bank
        public void SendInterBankTransfer(InterBankTransfer interBankTransfer)
        {
            var receiverBank = interBankTransfer.getReceiverBank();

            if (BankList.Contains(receiverBank))
            {
                receiverBank.receiveInterBankTransfer(interBankTransfer);
            }
        }
示例#4
0
文件: Bank.cs 项目: lukeses/bank
        public void receiveInterBankTransfer(InterBankTransfer interBankTransfer)
        {
            var receiverAccount = this.AccountList.Find(b => b.ID == interBankTransfer.getReceiverID());

            if (receiverAccount != null)
            {
                receiverAccount.Deposit(interBankTransfer.getAmount());
            }
            else
            {
                InterBankOfBank.SendBackInterBankTransfer(interBankTransfer);
            }
        }
示例#5
0
文件: Program.cs 项目: lukeses/bank
        static void Main(string[] args)
        {
            //            Account acc1 = new Account(65,"b", 500);
            //            Account acc2 = new Account(66, "C", 800);

            //            DebtAccount debtAccount = new DebtAccount(acc1);

            //            acc1.InterestRateMechanism.Handle(acc1);
            ////            var mechanism = acc1.InterestRate;

            //            Deposit dep = new Deposit();
            //            Withdrawal with = new Withdrawal();
            //            Transaction tran = new Transaction();
            //            Credit credit = new Credit();
            //            Bank bank = new Bank (90000);
            //            Bank bank_2 = new Bank(1200);

            //            Console.WriteLine("Account 1: {0} ", acc1.GetBalance());
            //            Console.WriteLine("Account 2: {0} ", acc2.GetBalance());
            //            credit.execute(acc1, bank, 140);
            //            dep.execute(acc1, 80);
            //            tran.execute(acc1, acc2, 60);
            //            with.execute(acc1, 50);
            //            Console.WriteLine("Credit request accepted. (T/F) \n {0}", credit.execute(acc1, bank, 140));

            //            //Console.WriteLine("Account 1: {0} ", acc1.balance);
            //            //Console.WriteLine("Account 2: {0} ", acc2.balance);
            //            //Console.WriteLine("Account 1: {0} ", acc1.balance);
            //            //Console.WriteLine("Account 1: {0} ", acc1.balance);
            //            Console.ReadLine();

            createInterBank();

            createAccount(MBank, 1, "Lukasz");
            createAccount(WBK, 2, "Tomasz");

            getAccount(MBank, 1).Deposit(100);
            getAccount(WBK, 2).Deposit(100);


            InterBankTransfer interBankTransfer = new InterBankTransfer(MBank, 1, WBK, 2, 100);

            MBank.sendInterBankTransfer(interBankTransfer);

            printBalance(getAccount(MBank, 1));
            printBalance(getAccount(WBK, 2));
        }