package jesse.keeblarcraft.BankMgr; import java.util.List; // Contains the information of an individuals player's bank account. // TODO: Add ability to store NBT data of items in the future so we can store not just money but items too // like a safety deposit box public class IndividualAccount { private String accountNumber; private String accountNumberAlias; private String routingNumber; // Will always be the bank it's in private List accountHolders; private Integer accountBalance; private Boolean allowNegativeBalance; private Boolean accountLocked; private String accountType; // TODO: Replace with enum in future. Valid is "checking" and "savings" right now public IndividualAccount() {} public IndividualAccount(String accountNumber, String routingNumber, List holders, Boolean allowNegativeBalance, Integer initialBalance, String alias) { this.accountNumber = accountNumber; this.routingNumber = routingNumber; this.accountHolders = holders; this.allowNegativeBalance = allowNegativeBalance; this.accountBalance = initialBalance; this.accountNumberAlias = alias; } public void AliasAccount(String newAlias) { this.accountNumberAlias = newAlias; } public Boolean IsLocked() { return accountLocked; } public Boolean Deposit(Integer amount) { Boolean success = false; if (!accountLocked) { accountBalance += amount; success = true; } return success; } public Boolean Withdraw(Integer amount) { Boolean success = false; if (!accountLocked) { // Determine remaining balance Integer remaining = accountBalance - amount; success = (remaining < 0 && !allowNegativeBalance); // Complete the transaction if successful if (success) { accountBalance = remaining; } } return success; } public Boolean CanWithdraw(Integer amount) { Boolean canWithdraw = false; if (!accountLocked && accountBalance - amount >= 0) { canWithdraw = true; } return canWithdraw; } public Boolean IsHolder(String name) { Boolean ret = false; if (accountHolders.contains(name)) { ret = true; } return ret; } public Boolean AllowsNegative() { return this.allowNegativeBalance; } public List GetAccountHolders() { return accountHolders; } public Integer GetAccountBalance() { return accountBalance; } public String GetAccountNumber() { return accountNumber; } public String GetRoutingNumber() { return routingNumber; } }