/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/30 12:30:07*/ /*This class drives: Account*/ package BankingSystem.core.humanResources; import java.util.*; import BankingSystem.*; import BankingSystem.core.intangableResources.*; import BankingSystem.core.tangableResources.*; import BankingSystem.json.*; public class Client extends PersonRole { //Class datatypes private String name; private String address; private String phoneNumber; //Class association variables private List accounts; //Registry of our system. BankingSystemRegistry registry = BankingSystemRegistry.getInstance(); //Constructor public Client(Person aPerson, String aName, String aAddress, String aPhoneNumber, ArrayList accounts) throws Exception { super(aPerson); name = aName; address = aAddress; phoneNumber = aPhoneNumber; this.accounts = accounts; } public boolean setName(String aName) { name = aName; return true; } public boolean setAddress(String aAddress) { address = aAddress; return true; } public boolean setPhoneNumber(String aPhoneNumber) { phoneNumber = aPhoneNumber; return true; } public String getName() { return name; } public String getAddress() { return address; } public String getPhoneNumber() { return phoneNumber; } public List getAccounts() { return accounts; } public Account addAccount(int aAccountNumber, Float aBalance, Float aCreditLimit, ArrayList clients, AccountType aAccountType, Branch aBranch) { Account newAccount; newAccount = new Account(aAccountNumber, aBalance, aCreditLimit, clients, aAccountType, aBranch); if (!accounts.contains(newAccount)) { registry.add(newAccount); accounts.add(newAccount); } return newAccount; } public Account addAccount(Account aAccount) { if (!accounts.contains(aAccount)) accounts.add(aAccount); return aAccount; } public void delete() { //Delete all many ends first. for (Account aAccount : accounts) { aAccount.delete(); } accounts.clear(); } public void deleteAccount(Account aAccount) { if (accounts.contains(aAccount)) { accounts.remove(aAccount); //registry.removeObj(registry.getKey(aAccount)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (accounts.size() == 0) { return true; } else return false; } /*********************************** * Returns the attribute list along with the * class ID in JSON format. ***********************************/ public JSONObject getAttributes() throws JSONException { JSONObject obj = new JSONObject(); obj.put("CLASS_ID", registry.getKey(this)); obj.put("name", getName()); obj.put("address", getAddress()); obj.put("phoneNumber", getPhoneNumber()); return obj; } }