コード例 #1
0
ファイル: UserInterface.cs プロジェクト: espanahenri/Project0
        public static void DisplayTransactionAccountScreen()
        {
            Console.Clear();
            CheckAccountsExist();
            var del = new ScreenDelegate(DisplayTransactionAccountScreen);
            int accountnumber;

            Console.WriteLine("+++Transactions+++");
            DisplayAllCustomerAccounts();
            Console.WriteLine("Please select the account you want to see the transactions for.");
            var input = Console.ReadLine();

            IntegerNumberVerifier(input, out accountnumber, del);
            AccountNumberExist(accountnumber, del);
            var account = AccountSelector(accountnumber);

            foreach (var transaction in account.Transactions)
            {
                Console.WriteLine($"Transaction Id: {transaction.TransactionID}|Type of Transaction: {transaction.TypeOfTransaction}" +
                                  $"|Time: {transaction.TimeOfTransaction}|Amount: ${transaction.Amount}");
            }
            Console.WriteLine("Please press enter to go back home.");
            Console.ReadLine();
            CustomerHomeScreen();
        }
コード例 #2
0
ファイル: UserInterface.cs プロジェクト: espanahenri/Project0
        public static void PayOverdraftScreen()
        {
            Console.Clear();
            decimal amount;
            var     del = new ScreenDelegate(PayOverdraftScreen);

            if (_CurrentCustomer.OverdraftFacilityDue > 0)
            {
                Console.WriteLine("+++Pay Overdraft Facility+++");
                Console.WriteLine($"This is how much you owe: ${ _CurrentCustomer.OverdraftFacilityDue.ToString("F")}");
                Console.WriteLine("How much would you like to pay?");
                var input = Console.ReadLine();
                VerifyAmount(input, out amount, del);
                if (amount > _CurrentCustomer.OverdraftFacilityDue)
                {
                    Console.WriteLine("Can't pay more than what you owe!");
                    Console.WriteLine("Press enter to continue.");
                    Console.ReadLine();
                    del();
                }
                _CurrentCustomer.OverdraftFacilityDue -= amount;
                Console.WriteLine("Thank you for your payment!");
                Console.WriteLine("Press enter to go back home");
                Console.ReadLine();
                CustomerHomeScreen();
            }
            Console.WriteLine("You dont owe any Overdraft Facilities.");
            Console.WriteLine("Press enter to go back home");
            Console.ReadLine();
            CustomerHomeScreen();
        }
コード例 #3
0
ファイル: UserInterface.cs プロジェクト: espanahenri/Project0
        public static void CloseAccountScreen()
        {
            Console.Clear();
            int accountnumber;
            var del = new ScreenDelegate(CloseAccountScreen);

            CheckAccountsExist();

            Console.WriteLine("+++Close Account+++");
            DisplayAllCustomerAccounts();
            Console.WriteLine("Type in the account number you want to close");
            var input = Console.ReadLine();

            IntegerNumberVerifier(input, out accountnumber, del);
            AccountNumberExist(accountnumber, del);
            if (AccountSelector(accountnumber) is Loan)
            {
                if (((Loan)(AccountSelector(accountnumber))).FullBalance > 0)
                {
                    Console.WriteLine("You cant close a loan that you still owe money.");
                    Thread.Sleep(2000);
                    del();
                }
            }
            CloseAccount(accountnumber);
            Console.WriteLine("You have successfully closed your account.");
            Console.WriteLine("Press Enter to go home.");
            Console.ReadLine();
            CustomerHomeScreen();
        }
コード例 #4
0
ファイル: UserInterface.cs プロジェクト: espanahenri/Project0
        public static void PayLoanInstallmentScreen()
        {
            Console.Clear();
            CheckAccountsExist();
            CheckNumberOfLoanAccounts();
            var     del    = new ScreenDelegate(PayLoanInstallmentScreen);
            decimal amount = 0.0m;
            int     accountnumber;

            Console.WriteLine("+++Loan Installment Payment+++");
            DisplayAllCustomerAccounts();
            Console.WriteLine("Type the account number of the loan you want to pay.");
            var input = Console.ReadLine();

            IntegerNumberVerifier(input, out accountnumber, del);
            AccountNumberExist(accountnumber, del);
            if (!(AccountSelector(accountnumber) is Loan))
            {
                Console.WriteLine("Sorry that is not a Loan Account. Try Again");
                Console.WriteLine("Press enter to try again.");
                Console.ReadLine();
                del();
            }
            Loan loanaccount = (Loan)AccountSelector(accountnumber);

            Console.WriteLine($"This is your monthly due: ${loanaccount.InstallmentAmount.ToString("F")}");
            Console.WriteLine("How much would you like to pay?");
            input = Console.ReadLine();
            VerifyAmount(input, out amount, del);
            if (amount > loanaccount.FullBalance)
            {
                Console.WriteLine("Cannot pay more than what you currently owe.");
                Thread.Sleep(2000);
                del();
            }
            if (amount == loanaccount.FullBalance)
            {
                Console.WriteLine("Congratulations you have paid your full loan.");
                Thread.Sleep(2000);
                loanaccount.isActive = false;
                CloseAccount(accountnumber);
            }
            loanaccount.FullBalance -= amount;
            var tran = new Transaction()
            {
                TransactionID     = _TransactionID,
                TimeOfTransaction = DateTime.Now,
                Amount            = amount,
                TypeOfTransaction = "Payment",
                AccountNumber     = loanaccount.AccountNumber
            };

            loanaccount.Transactions.Add(tran);
            Console.WriteLine("Thank you for your payment!");
            Console.WriteLine("Press enter to go back to home screen.");
            Console.ReadLine();
            CustomerHomeScreen();
        }
コード例 #5
0
ファイル: UserInterface.cs プロジェクト: espanahenri/Project0
 private static void VerifyYear(int year, ScreenDelegate del)
 {
     if (year <= 0)
     {
         Console.WriteLine("Invalid Value.");
         Thread.Sleep(2000);
         del();
     }
 }
コード例 #6
0
ファイル: UserInterface.cs プロジェクト: espanahenri/Project0
 public static void AccountNumberExist(int accountnumber, ScreenDelegate del)
 {
     if (!(_CurrentCustomer.Accounts.Any(account => account.AccountNumber == accountnumber)))
     {
         Console.WriteLine("Account number not found. Try again.");
         Thread.Sleep(2000);
         del();
     }
 }
コード例 #7
0
ファイル: UserInterface.cs プロジェクト: espanahenri/Project0
        public static void DepositScreen()
        {
            Console.Clear();
            var     del = new ScreenDelegate(DepositScreen);
            decimal amount;
            int     accountnumber;

            CheckAccountsExist();
            Console.WriteLine("+++Deposit+++");
            Console.WriteLine("Select account you want to deposit into:");
            DisplayAllCustomerAccounts();
            Console.WriteLine("Please type in account number you want to deposit in to.");
            var input = Console.ReadLine();

            IntegerNumberVerifier(input, out accountnumber, del);
            AccountNumberExist(accountnumber, del);
            CheckLoanType(accountnumber);
            if (AccountSelector(accountnumber) is TermDeposit)
            {
                Console.WriteLine("Sorry you cannot transfer to a cd.");
                Console.WriteLine("Press enter to try again.");
                Console.ReadLine();
                CustomerHomeScreen();
            }
            var account = (IAccountV1)AccountSelector(accountnumber);

            Console.WriteLine("How much do you want to deposit?");
            input = Console.ReadLine();
            VerifyAmount(input, out amount, del);

            account.Deposit(amount);
            var trans = new Transaction()
            {
                TransactionID     = _TransactionID,
                TimeOfTransaction = DateTime.Now,
                Amount            = amount,
                TypeOfTransaction = "Deposit",
                AccountNumber     = account.AccountNumber
            };

            if (account.Transactions == null)
            {
                account.Transactions = new List <Transaction>();
            }
            account.Transactions.Add(trans);
            _TransactionID++;
            Console.WriteLine($"Thank you, your deposit of ${amount.ToString("F")} for account: {account.AccountNumber } was successful");
            Console.WriteLine("Please press enter to go back home.");
            Console.ReadLine();
            CustomerHomeScreen();
        }
コード例 #8
0
ファイル: Loon.cs プロジェクト: ntthanh/LGame
 /// <summary>
 /// 以Delegate委托方式注入初始数据
 /// </summary>
 /// <param name="s"></param>
 /// <param name="data"></param>
 public virtual void Register(LSetting s, ScreenDelegate data)
 {
     if (s is MonoGameSetting mgs)
     {
         this._setting = mgs;
     }
     else
     {
         MonoGameSetting tmp = new MonoGameSetting();
         tmp.Copy(s);
         tmp.fullscreen = true;
         this._setting  = tmp;
     }
     this._mainDelegateData = data;
 }
コード例 #9
0
ファイル: UserInterface.cs プロジェクト: espanahenri/Project0
        public static void WithdrawScreen()
        {
            Console.Clear();

            var     del    = new ScreenDelegate(WithdrawScreen);
            decimal amount = 0.0m;
            int     accountnumber;

            CheckAccountsExist();
            Console.WriteLine(" +++WITHDRAW+++");
            Console.WriteLine("Select the account");
            DisplayAllCustomerAccounts();
            Console.WriteLine("Type the number of the account.");
            var input = Console.ReadLine();

            IntegerNumberVerifier(input, out accountnumber, del);
            AccountNumberExist(accountnumber, del);
            CheckLoanType(accountnumber);
            var account = (IAccountV1)AccountSelector(accountnumber);

            Console.WriteLine("How much would you like to withdraw?");
            input = Console.ReadLine();
            VerifyAmount(input, out amount, del);
            account.Withdraw(amount);
            if (account is TermDeposit)
            {
                CloseAccount(accountnumber);
            }
            var trans = new Transaction()
            {
                TransactionID     = _TransactionID,
                TimeOfTransaction = DateTime.Now,
                Amount            = amount,
                TypeOfTransaction = "Withdraw",
                AccountNumber     = account.AccountNumber
            };

            if (account.Transactions == null)
            {
                account.Transactions = new List <Transaction>();
            }
            account.Transactions.Add(trans);
            _TransactionID++;
            Console.WriteLine($"Thank you, your withdraw of ${amount.ToString("F")} for account: {account.AccountNumber } was successful");
            Console.WriteLine("Please press enter to go back home.");
            Console.ReadLine();
            CustomerHomeScreen();
        }
コード例 #10
0
ファイル: UserInterface.cs プロジェクト: espanahenri/Project0
        private static void VerifyAmount(string input, out decimal amount, ScreenDelegate del)
        {
            bool checknumber = Decimal.TryParse(input, out amount);

            if (amount < 0)
            {
                Console.WriteLine("Amount cannot be less than zero.");
                Thread.Sleep(2000);
                del();
            }
            if (checknumber == false)
            {
                Console.WriteLine("Not a correct value. Try again.");
                Thread.Sleep(2000);
                del();
            }
        }
コード例 #11
0
ファイル: UserInterface.cs プロジェクト: espanahenri/Project0
        private static void OpenTermDeposit()
        {
            Console.Clear();
            decimal amount;
            int     years;
            var     del = new ScreenDelegate(OpenTermDeposit);

            Console.WriteLine("How much would you like to deposit?");
            var input = Console.ReadLine();

            VerifyAmount(input, out amount, del);
            Console.WriteLine("How long do want your term to be(years)?");
            input = Console.ReadLine();
            IntegerNumberVerifier(input, out years, del);
            VerifyYear(years, del);
            var account = new TermDeposit()
            {
                AccountNumber = _TermDepositID,
                Balance       = amount,
                Term          = years,
                Maturity      = DateTime.Now.AddYears(years),
                isActive      = true,
                InterestRate  = 0.10,
                CustomerID    = _CurrentCustomer.ID,
                Transactions  = new List <Transaction>(),
            };

            account.Deposit(amount);
            _CurrentCustomer.Accounts.Add(account);
            var tran = new Transaction()
            {
                TransactionID     = _TransactionID,
                TypeOfTransaction = "Deposit",
                Amount            = amount,
                TimeOfTransaction = DateTime.Now,
                AccountNumber     = _TermDepositID
            };

            AccountSelector(_TermDepositID).Transactions.Add(tran);
            _TermDepositID++;
            Console.WriteLine($"You have created a new CD which will mature on {account.Maturity}");
            Console.WriteLine("Press enter to go back home");
            Console.ReadLine();
            CustomerHomeScreen();
        }
コード例 #12
0
ファイル: UserInterface.cs プロジェクト: espanahenri/Project0
        private static void OpenLoan()
        {
            Console.Clear();
            decimal amount;
            int     years;
            var     del = new ScreenDelegate(OpenLoan);

            Console.WriteLine("How much would you like to loan?");
            var input = Console.ReadLine();

            VerifyAmount(input, out amount, del);
            Console.WriteLine("How long do want your term to be(years)?");
            input = Console.ReadLine();
            IntegerNumberVerifier(input, out years, del);
            VerifyYear(years, del);
            var account = new Loan()
            {
                AccountNumber = _LoanID,
                Balance       = amount,
                Term          = years,
                isActive      = true,
                InterestRate  = 0.10,
                CustomerID    = _CurrentCustomer.ID,
                Transactions  = new List <Transaction>()
            };

            account.FullBalance       = amount + (decimal)((double)amount * account.InterestRate);
            account.InstallmentAmount = (decimal)(account.FullBalance / (account.Term * 12));
            _CurrentCustomer.Accounts.Add(account);
            _LoanID++;
            Console.WriteLine($"You have taken out a new loan for ${account.Balance.ToString("F")} with a monthly payment " +
                              $"of ${account.InstallmentAmount.ToString("F")} for {account.Term} years.");
            Console.WriteLine("Press enter to go back home");
            Console.ReadLine();
            CustomerHomeScreen();
        }
コード例 #13
0
ファイル: UserInterface.cs プロジェクト: espanahenri/Project0
        private static void IntegerNumberVerifier(string input, out int accountnumber, ScreenDelegate del)
        {
            bool checknumber = int.TryParse(input, out accountnumber);

            if (checknumber == false)
            {
                Console.WriteLine("Not a correct value. Try again");
                Thread.Sleep(2000);
                del();
            }
        }
コード例 #14
0
ファイル: UserInterface.cs プロジェクト: espanahenri/Project0
        public static void TransferScreen()
        {
            Console.Clear();
            CheckAccountsExist();
            CheckNumberOfAccounts();
            var     del    = new ScreenDelegate(TransferScreen);
            decimal amount = 0.0m;
            int     accountnumberfrom;
            int     accountnumberto;

            Console.WriteLine("+++Transfer+++");
            DisplayAllCustomerAccounts();
            Console.WriteLine("Type the account number where you want to transfer from.");
            var input = Console.ReadLine();

            IntegerNumberVerifier(input, out accountnumberfrom, del);
            AccountNumberExist(accountnumberfrom, del);
            CheckLoanType(accountnumberfrom);
            Console.WriteLine("Type the account number where you want to transfer to.");
            input = Console.ReadLine();
            IntegerNumberVerifier(input, out accountnumberto, del);
            AccountNumberExist(accountnumberto, del);
            CheckLoanType(accountnumberto);
            if (AccountSelector(accountnumberto) is TermDeposit)
            {
                Console.WriteLine("Sorry you cannot transfer to a cd.");
                Console.WriteLine("Press enter to try again.");
                Console.ReadLine();
                del();
            }
            if (accountnumberfrom == accountnumberto)
            {
                Console.WriteLine("Sorry you cannot transfer to the same account.");
                Console.WriteLine("Press enter to try again.");
                Console.ReadLine();
                del();
            }
            Console.WriteLine("How much would you like to transfer");
            input = Console.ReadLine();
            VerifyAmount(input, out amount, del);
            var accfrom = (IAccountV1)AccountSelector(accountnumberfrom);
            var accto   = (IAccountV1)AccountSelector(accountnumberto);

            accfrom.Withdraw(amount);
            if (accfrom is TermDeposit)
            {
                CloseAccount(accfrom.AccountNumber);
            }
            accto.Deposit(amount);
            var transfrom = new Transaction()
            {
                TransactionID     = _TransactionID,
                TimeOfTransaction = DateTime.Now,
                Amount            = amount,
                TypeOfTransaction = "Withdraw",
                AccountNumber     = accfrom.AccountNumber
            };

            if (accfrom.Transactions == null)
            {
                accfrom.Transactions = new List <Transaction>();
            }
            accfrom.Transactions.Add(transfrom);
            _TransactionID++;
            var transto = new Transaction()
            {
                TransactionID     = _TransactionID,
                TimeOfTransaction = DateTime.Now,
                Amount            = amount,
                TypeOfTransaction = "Deposit",
                AccountNumber     = accfrom.AccountNumber
            };

            if (accto.Transactions == null)
            {
                accto.Transactions = new List <Transaction>();
            }
            accto.Transactions.Add(transto);
            _TransactionID++;
            Console.WriteLine("Transfer Complete!");
            Console.WriteLine("Press enter to go back to home screen.");
            Console.ReadLine();
            CustomerHomeScreen();
        }