class Account
{
public static void closeAcct()
{
int account;
account = chooseAccount();
if (account == -1)
return;
if (acctActive[account] == false)
System.out.println("Account is not active.");
else if (acctActive[account] == true)
...
}
public static void openAcct()
{
int account;
account = chooseAccount();
if (account == -1)
return;
if (acctActive[account] == true)
...
}
... // same for: doDeposit(), doWithdrawl(), and showBalance()
}
|
class Account
{
public static boolean isAccountActive(int account)
{
if((account >= 0) && (account < acct.length))
return acctActive[account];
else
throw new IllegalArgumentException("Invalid Account");
}
public static void closeAcct(int account)
{
if (isAccountActive(account) == false)
...
}
public static void openAcct(int account)
{
if (isAccountActive(account) == true)
...
}
... // etcetera
}
|