public int getBalenceInfo(int pin) { if (pin == conta.getPin()) { return conta.getBalance(); } else { System.out.println("Wrong Pin"); return 0; } }
public Account identify(int accountNumber, int pin) { Account identifiedAccount = null; for (Account account : accounts) { if (account.getAccountNumber() == accountNumber && account.getPin() == pin) { identifiedAccount = account; break; } } return identifiedAccount; }
public int getMoneyFromAccout(int pin, int value) { if (pin == conta.getPin()) { conta.setBalance(conta.getBalance() - value); totalMoney -= value; System.out.println("Operation completed"); return value; } else { System.out.println("Wrong Pin"); return 0; } }
public void printHighestBalance() { // prints the accounts from highest amount to lowest, with those who have empty accounts last ajf.dispose(); ajf = new AdminRunningFrame(this); StringBuilder stringResults = new StringBuilder(); String header = header(); stringResults.append(header); if (!cust.isEmpty()) { ArrayList<Account> allAccounts = new ArrayList<Account>(); ArrayList<Customer> CustomersNoAccounts = new ArrayList<Customer>(); for (Customer c : cust) { ArrayList<Account> accounts = c.getAccounts(); if (!accounts.isEmpty()) { // Concatenates all the accounts together for easy sorting allAccounts.addAll(accounts); } // Adds customers without accounts to a separate list to be printed at the end of all the // others else { CustomersNoAccounts.add(c); } } if (!allAccounts.isEmpty()) { Collections.sort(allAccounts, Account.CompareBalances); for (Account a : allAccounts) { if (a.checkActive()) { String id = a.getID(); String name = a.getName().toUpperCase(); String pin = a.getPin(); String accountNumber = a.returnNumber(); double balance = a.returnBalance(); String balanceAsString = formatter.format(balance); String customerInfo = printAdminInfo(name, id, accountNumber, pin, balanceAsString); stringResults.append(customerInfo); } } } if (!CustomersNoAccounts.isEmpty()) { Collections.sort(CustomersNoAccounts, Customer.CompareName); for (Customer c : CustomersNoAccounts) { String id = c.returnID(); String name = c.getName().toUpperCase(); String pin = c.returnPin(); String noAccounts = String.format("%-20s %-9s %-10s\n", name, id, pin); stringResults.append(noAccounts); } } String resultsAsString = stringResults.toString(); ajf.printInfo(resultsAsString); } }