/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/30 12:30:06*/ /*This class drives: Card*/ package BankingSystem.core.intangableResources; import java.sql.Date; import java.util.*; import BankingSystem.*; import BankingSystem.core.humanResources.*; import BankingSystem.core.tangableResources.*; import BankingSystem.json.*; public class CreditCardAccount extends Account { //Class datatypes private Date expiryDate; //Class association variables private List cards; //Registry of our system. BankingSystemRegistry registry = BankingSystemRegistry.getInstance(); //Constructor public CreditCardAccount(int aAccountNumber, Float aBalance, Float aCreditLimit, ArrayList clients, AccountType aAccountType, Branch aBranch, Date aExpiryDate, ArrayList cards) { super(aAccountNumber, aBalance, aCreditLimit, clients, aAccountType, aBranch); expiryDate = aExpiryDate; this.cards = cards; } public boolean setExpiryDate(Date aExpiryDate) { expiryDate = aExpiryDate; return true; } public Date getExpiryDate() { return expiryDate; } public List getCards() { return cards; } public Card addCard(String aHolderName, CreditCardAccount aCreditCardAccount) { Card newCard; newCard = new Card(aHolderName, this); if (!cards.contains(newCard)) { registry.add(newCard); cards.add(newCard); } return newCard; } public Card addCard(Card aCard) { if (!cards.contains(aCard)) cards.add(aCard); return aCard; } public void delete() { //Delete all many ends first. for (Card aCard : cards) { aCard.delete(); } cards.clear(); } public void deleteCard(Card aCard) { if (cards.contains(aCard)) { cards.remove(aCard); //registry.removeObj(registry.getKey(aCard)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (cards.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("expiryDate", getExpiryDate()); return obj; } }