コード例 #1
0
        public override void MakeWithdrawal(decimal withdrawal, DateTime dateTime)
        {
            AccountManager accountManager = new AccountManager();

            if (dateTime < DateOfTransaction.AddYears(1))
            {
                Console.WriteLine("Cannot make a withdrawal until end of term");
            }
            else if (withdrawal != Balance)
            {
                Console.WriteLine("Must withdraw full amount from your Certificate Deposit");
            }
            else
            {
                string withdrawalString = withdrawal.ToString();
                WithdrawalString = "+$" + withdrawalString;
                WithdrawalAmount = withdrawal;
                Balance         -= withdrawal;
                var completeWithdrawal = new Transaction(Balance, WithdrawalString, WithdrawalAmount, dateTime);
                transactions.Add(completeWithdrawal);
                UI.CloseCDOnWithdrawal();
                Console.WriteLine("This account will now be closed.");
                UI.OnEnterPress();
                Program.ExecuteUserInput();
            }
        }
コード例 #2
0
        public override void MakeWithdrawal(decimal withdrawal, DateTime dateTime)
        {
            string withdrawalString = withdrawal.ToString();

            WithdrawalString  = "-$" + withdrawalString;
            WithdrawalAmount  = withdrawal;
            DateOfTransaction = dateTime;
            Balance          -= WithdrawalAmount;
            if (WithdrawalAmount <= 0)
            {
                Console.WriteLine("Withdrawal amount must be positive.");
                UI.OnEnterPress();
                Program.ExecuteUserInput();
            }
            else if (WithdrawalAmount > 0 && Balance < 0)
            {
                Console.WriteLine("You've overdrafted your account. An interest of {0} will be added to your new outstanding balance", InterestRate);
                Balance += (Balance * InterestRate);
                var completeDeposit = new Transaction(Balance, WithdrawalString, WithdrawalAmount, DateOfTransaction);
                transactions.Add(completeDeposit);
                UI.OnEnterPress();
                Program.ExecuteUserInput();
            }
            else
            {
                Balance -= WithdrawalAmount;
                Console.WriteLine("Withdrawal of {0} was successful.", WithdrawalAmount);
                var completeDeposit = new Transaction(Balance, WithdrawalString, WithdrawalAmount, DateOfTransaction);
                transactions.Add(completeDeposit);
            }
        }
コード例 #3
0
ファイル: Loan.cs プロジェクト: DreamEther/Revature-Project-0
 public void MakePayment(decimal payment, DateTime dateTime)
 {
     if (payment <= 0)
     {
         Console.WriteLine("Payment amount must be greater than zero");
         UI.OnEnterPress();
         Program.ExecuteUserInput();
     }
     else if (payment > Balance)
     {
         Console.WriteLine("The intended payment is more than your outstanding loan. Please enter an amount less than or equal to your outstanding loan");
         UI.OnEnterPress();
         Program.ExecuteUserInput();
     }
     else
     {
         string depositString = payment.ToString();
         DepositString     = "+$" + depositString;
         DateOfTransaction = dateTime.AddYears(-1);
         DepositAmount     = payment;
         Balance          -= DepositAmount;
         decimal roundedBalance = Decimal.Round(Balance, 2);
         Balance = roundedBalance;
         var makePayment = new Transaction(Balance, DepositString, DepositAmount, DateOfTransaction);
         transactions.Add(makePayment);
         Console.WriteLine("Payment recieved!");
         UI.OnEnterPress();
         Program.ExecuteUserInput();
     }
 }
コード例 #4
0
        public override void MakeWithdrawal(decimal withdrawal, DateTime dateTime)
        {
            string withdrawalString = withdrawal.ToString();

            WithdrawalString  = "-$" + withdrawalString;
            WithdrawalAmount  = withdrawal;
            DateOfTransaction = dateTime;
            decimal newBalance = Balance - WithdrawalAmount;

            if (WithdrawalAmount <= 0)
            {
                Console.WriteLine("Withdrawal amount must be positive.");
                UI.OnEnterPress();
                Program.ExecuteUserInput();
            }
            else if (WithdrawalAmount > 0 && newBalance < 0)
            {
                Console.WriteLine("You do not have sufficient funds for this withdrawal.");
                UI.OnEnterPress();
                Program.ExecuteUserInput();
            }
            else
            {
                Balance -= WithdrawalAmount;
                var completeDeposit = new Transaction(Balance, WithdrawalString, DepositAmount, DateOfTransaction);
                transactions.Add(completeDeposit);
            }
        }
コード例 #5
0
ファイル: Loan.cs プロジェクト: DreamEther/Revature-Project-0
 public override void MakeWithdrawal(decimal loanAmount, DateTime timeOfLoan)
 {
     if (Balance > 0)
     {
         Console.WriteLine("Cannot make withdrawals on a loan. Please take out another loan or make a payment on an existing loan");
         UI.OnEnterPress();
         Program.ExecuteUserInput();
     }
     else
     {
         DateOfTransaction = timeOfLoan;
         LoanAmount        = loanAmount;
         string loanString = LoanAmount.ToString();
         LoanString = "+$" + loanString;
         Balance   += LoanAmount;
         Balance   += (Balance * InterestRate);
         decimal roundedBalance = Decimal.Round(Balance, 2);
         Balance = roundedBalance;
         var completeLoan = new Transaction(Balance, LoanString, LoanAmount, DateOfTransaction);
         transactions.Add(completeLoan);
         Console.WriteLine("You've successfully taken out a loan!");
         Console.WriteLine("Interest rate of {0}% will be added to your loan", interest);
         UI.OnEnterPress();
         Program.ExecuteUserInput();
     }
 }
コード例 #6
0
 public void CloseAccount(Account account, Customer customer)
 {
     _customer = customer;
     _account  = account;
     if (_account.Balance > 0)
     {
         Console.Clear();
         Console.WriteLine("Account must have a balance of $0 in order for you to close it.");
         UI.OnEnterPress();
         Program.ExecuteUserInput();
     }
     else
     {
         _customer.listOfAccounts.Remove(_account);
         Console.WriteLine($"Account {_account.AccountID} has been closed.");
         Console.Clear();
         Program.ExecuteUserInput();
     }
 }
コード例 #7
0
 public void Transfer(Account account1, Account account2, decimal withdrawalAmount)
 {
     _amount = withdrawalAmount;
     if (account1.AccountType == "Certificate Deposit" && account1.WithdrawalAmount != account1.Balance)
     {
         account1.MakeWithdrawal(_amount, DateTime.Now);
     }
     else if (account1.AccountType == "Loan")
     {
         Console.WriteLine("Cannot make a transfer from accounts of type loan!");
         UI.OnEnterPress();
         Program.ExecuteUserInput();
     }
     else
     {
         account1.MakeWithdrawal(_amount, DateTime.Now);
         account2.MakeDeposit(withdrawalAmount, DateTime.Now);
         Console.WriteLine("Transfer succeeded!");
     }
 }
コード例 #8
0
        public virtual void MakeDeposit(decimal deposit, DateTime dateTime)
        {
            if (deposit <= 0)
            {
                Console.WriteLine("Deposit must be greater than 0");
                UI.OnEnterPress();
                Program.ExecuteUserInput();
            }
            string depositString = deposit.ToString();

            DepositString = "+$" + depositString;
            String.Format("{0:0.00}", DepositString);
            DepositAmount     = deposit;
            DateOfTransaction = dateTime;
            Balance          += DepositAmount;
            decimal roundedBalance = Decimal.Round(Balance, 2);

            Balance = roundedBalance;
            var completeDeposit = new Transaction(Balance, DepositString, DepositAmount, DateOfTransaction);

            transactions.Add(completeDeposit);
        }
コード例 #9
0
 public override void MakeDeposit(decimal deposit, DateTime dateTime)
 {
     if (Balance > 0)
     {
         Console.WriteLine("Cannot make another deposit until term maturity is reached");
         UI.OnEnterPress();
         Program.ExecuteUserInput();
     }
     if (deposit <= 0)
     {
         Console.WriteLine("Deposit amount must be positive");
         UI.OnEnterPress();
         Program.ExecuteUserInput();
     }
     if (deposit > 0 && deposit < 500)
     {
         Console.WriteLine("Term deposit must be $500 or greater...");
         UI.OnEnterPress();
         Program.ExecuteUserInput();
     }
     else
     {
         string depositString = deposit.ToString();
         DepositString     = "+$" + depositString;
         DateOfTransaction = dateTime.AddYears(-1);
         DepositAmount     = deposit;
         Balance          += deposit;
         Balance          += (Balance * InterestRate) * 12;
         decimal roundedBalance = Decimal.Round(Balance, 2);
         Balance = roundedBalance;
         var completeDeposit = new Transaction(Balance, DepositString, DepositAmount, DateOfTransaction);
         transactions.Add(completeDeposit);
         Console.WriteLine("At the end of 12 months, your balance after interest will be {0}", Balance);
         Console.WriteLine("You may withdraw your intial deposit and the interest accumulated on it at that time.");
         UI.OnEnterPress();
         Program.ExecuteUserInput();
     }
 }
コード例 #10
0
ファイル: Loan.cs プロジェクト: DreamEther/Revature-Project-0
 public override void MakeDeposit(decimal payment, DateTime dateTime)
 {
     Console.WriteLine("Please select the 'Make a Payment' option to make a payment on your loan");
     UI.OnEnterPress();
     Program.ExecuteUserInput();
 }