Ejemplo n.º 1
0
        public void CreateAccount(int Number, int Balance, string Label, int Owner)
        {
            Account account = new Account(Number, Balance, Label, Owner);

            accounts.Add(account);
            JSONFileService.Save(accounts);
        }
Ejemplo n.º 2
0
        public void MoveBalance(int outgoingAccountNumber, int incomingAccountNumber, int amount)
        {
            int outgoingIndex = GetAccountIndexByNumber(outgoingAccountNumber);
            int incomingIndex = GetAccountIndexByNumber(incomingAccountNumber);

            if (amount < 0)
            {
                Console.WriteLine("Invalid amount.");
                return;
            }
            if (amount > accounts[outgoingIndex].Balance)
            {
                Console.WriteLine("Balance too low.");
                return;
            }

            accounts[outgoingIndex].Balance -= amount;
            accounts[incomingIndex].Balance += amount;

            JSONFileService.Save(accounts);
        }