Exemplo n.º 1
0
 public static void Overdraft(string accId, decimal ammount, out bool canOverdraft, out decimal deposit)
 {
     canOverdraft = true;
     if (AccountStore.StoredAccounts[accId].CanOverdraft)
     {
         Console.WriteLine("You have overdrafted on account: " + accId);
         if (AccountStore.StoredAccounts[accId]._AssociatedAccountId is null)
         {
             deposit  = ammount;
             ammount -= AccountBalance.Balance[accId];
             TransactionStore.AddTransferTransaction(accId, null, AccountStore.AccCharToId[accId[0]], 2, AccountBalance.Balance[accId]);
             AccountBalance.Balance[accId] = 0;
             AccCreator.OverCreator(accId, ammount);
             Console.WriteLine("You now have an overdraft faucility: " + AccountStore.StoredAccounts[accId]._AssociatedAccountId +
                               " associated with account: " + accId + " for $" + ammount);
         }
         else
         {
             deposit = ammount;
             string AaccId = AccountStore.StoredAccounts[accId]._AssociatedAccountId;
             AccountBalance.Balance[AaccId] += ammount;
             TransactionStore.AddTransferTransaction(AaccId, null, 4, 2, ammount);
             Console.WriteLine("You now owe $" + AccountBalance.Balance[AccountStore.StoredAccounts[accId]._AssociatedAccountId] +
                               " on account: " + accId);
         }
     }
     else
     {
         Console.WriteLine("You cannot overdraft from a " + AccountStore.AccCharToName[accId[0]] + " account!");
         canOverdraft = false;
         deposit      = 0;
     }
 }
Exemplo n.º 2
0
        public static void TermMature(string TermaccId, decimal ammount)
        {
            AccountStore.addAccountid('c');
            string   AccId       = AccountStore.lastmadeAccId;
            Checking newChecking = new Checking(AccId);

            AccountStore.addAccount(AccId, newChecking);
            AccountBalance.setBalance(AccId, ammount);
            AccountBalance.setBalance(TermaccId, 0);
            TransactionStore.AddTransferTransaction(AccId, null, 0, 0, ammount);
            TransactionStore.AddTransferTransaction(TermaccId, null, 3, 5, ammount);
            AccCreator.AccountCloser(TermaccId);
        }
Exemplo n.º 3
0
        public static void MenuRedirect(int input)
        {
            switch (input)
            {
            case 0:
                AccCreator.Greeting();
                AccCreator.ParseInput();
                AccCreator.Creator(AccCreator.parsedInput);
                break;

            case 1:
                AccCreator.AccountCloser();
                break;

            case 2:
                BalanceTransact.SelectAcc('w');
                break;

            case 3:
                BalanceTransact.SelectAcc('d');
                break;

            case 4:
                BalanceTransact.SelectAcc('t');
                break;

            case 5:
                BalanceTransact.Pay();
                break;

            case 6:
                AccViewer.getAccounts();
                break;

            case 7:
                TransactionViewer.Display();
                break;

            case 8:
                TimeSim.PassTime();
                break;
            }
        }
Exemplo n.º 4
0
        public static void Pay()
        {
            int existCheck = 0;
            Dictionary <string, object> canPay = new Dictionary <string, object>();

            foreach (KeyValuePair <string, Account> entry in AccountStore.StoredAccounts)
            {
                if (entry.Value.AccountId[0] == 'l' || entry.Value.AccountId[0] == 'o')
                {
                    canPay.Add(entry.Key, entry.Value);
                }
            }
            if (canPay.Count == 0)
            {
                Console.WriteLine("You have no accounts to pay");
            }
            else
            {
                Console.WriteLine("Which account would you like to pay?");
                while (true)
                {
                    Console.WriteLine("|{0,-15}|{1,-20}|", "AccountId", "Balance");
                    Console.WriteLine("|" + new string('-', 15) + '|' + new string('-', 20) + "|");
                    foreach (KeyValuePair <string, object> entry in canPay)
                    {
                        Console.WriteLine("|{0,-15}|{1,-20}|", entry.Key, AccountBalance.Balance[entry.Key]);
                    }
                    string accId = Console.ReadLine();
                    if (canPay.ContainsKey(accId))
                    {
                        Console.WriteLine("How much would you like to pay?");
                        input  = Console.ReadLine();
                        parsed = decimal.TryParse(input, out _checkedInput);
                        if (parsed && _checkedInput >= 0)
                        {
                            bool    didClose;
                            bool    exit;
                            decimal output;
                            _checkedInput = Math.Round(_checkedInput, 2);
                            Payment(accId, _checkedInput, out output, out didClose);
                            if (didClose == true)
                            {
                                if (!(AccountStore.StoredAccounts[accId]._AssociatedAccountId is null))
                                {
                                    AccountStore.StoredAccounts[AccountStore.StoredAccounts[accId]._AssociatedAccountId]._AssociatedAccountId = null;
                                }
                                AccCreator.AccountCloser(accId);
                                break;
                            }
                            Console.WriteLine("Your new balance is: $" + AccountBalance.Balance[accId] +
                                              "\nWould you like to pay more? (y/n)");
                            Parsers.YNCheck();
                            exit = Parsers.YNtoBool[Parsers.parsedYN];
                            if (!exit == true)
                            {
                                break;
                            }
                        }
                        else
                        {
                            Parsers.InvalidInput();
                        }
                    }
                    else
                    {
                        Parsers.InvalidInput();
                    }
                }
            }
        }
        public static void Creator(int selection)
        {
            void StateCreated()
            {
                Console.WriteLine("\nAccount " + AccountStore.lastmadeAccId + " has been created!");
                AccountBalance.getBalance(AccountStore.lastmadeAccId);
            }

            switch (selection)
            {
            case 0:
                AccountStore.addAccountid('c');
                AccId = AccountStore.lastmadeAccId;
                Checking newChecking = new Checking(AccId);
                AccountStore.addAccount(AccId, newChecking);
                BalanceTransact.Deposit();
                AccountBalance.setBalance(AccId, BalanceTransact.checkedInput);
                StateCreated();
                TransactionStore.AddTransferTransaction(AccId, null, 0, 0, BalanceTransact.checkedInput);
                break;

            case 1:
                AccountStore.addAccountid('b');
                AccId = AccountStore.lastmadeAccId;
                Business newBusiness = new Business(AccId);
                AccountStore.addAccount(AccId, newBusiness);
                BalanceTransact.Deposit();
                AccountBalance.setBalance(AccId, BalanceTransact.checkedInput);
                StateCreated();
                TransactionStore.AddTransferTransaction(AccId, null, 1, 0, BalanceTransact.checkedInput);
                break;

            case 2:
                AccountStore.addAccountid('l');
                AccId = AccountStore.lastmadeAccId;
                AccCreator.setInterest();
                AccCreator.setInstallment();
                AccCreator.setInitialAmount();
                Loan newLoan = new Loan(AccId, AccCreator.InterestRate, AccCreator.InstallmentTypeId, AccCreator.InitialAmount);
                AccountStore.addAccount(AccId, newLoan);
                AccountBalance.setBalance(AccId, AccCreator.InitialAmount);
                StateCreated();
                TransactionStore.AddTransferTransaction(AccId, null, 2, 0, AccCreator.InitialAmount);
                break;

            case 3:
                AccountStore.addAccountid('t');
                AccId = AccountStore.lastmadeAccId;
                AccCreator.setInterest();
                AccCreator.setInitialAmount();
                TermDeposit newCD = new TermDeposit(AccId, InterestRate);
                AccountStore.addAccount(AccId, newCD);
                AccountBalance.setBalance(AccId, AccCreator.InitialAmount);
                StateCreated();
                TransactionStore.AddTransferTransaction(AccId, null, 3, 0, AccCreator.InitialAmount);
                break;

            default:
                Console.WriteLine("That is not a valid selection");
                return;
            }
        }