/*This code was generated using the UMPLE modeling language!
 Date of generation: 2008/07/30 12:30:07*/
/*This class drives: */

package BankingSystem.core.tangableResources;

import java.sql.Date;
import BankingSystem.*;
import BankingSystem.core.humanResources.*;
import BankingSystem.core.intangableResources.*;
import BankingSystem.json.*;

public class Card {
  //Class datatypes
  private String holderName;

  //Class association variables
  private CreditCardAccount creditCardAccount;

  //Registry of our system.
  BankingSystemRegistry registry = BankingSystemRegistry.getInstance();

  //Constructor
  public Card(String aHolderName, CreditCardAccount aCreditCardAccount) {
    holderName = aHolderName;
    creditCardAccount = aCreditCardAccount;
    creditCardAccount.addCard(this);

  }

  public boolean setHolderName(String aHolderName) {
    holderName = aHolderName;
    return true;
  }

  public String getHolderName() {
    return holderName;
  }

  public CreditCardAccount getCreditCardAccount() {
    return creditCardAccount;
  }

  /* This class does not drive CreditCardAccount and therefore sets the association unidirectionally.*/
  public void setCreditCardAccount(CreditCardAccount aCreditCardAccount) {
    creditCardAccount = aCreditCardAccount;
  }

  public void delete() {
    //Delete all 1 ends.
    creditCardAccount.delete();
  }

  public boolean areManyEndsNull() {
    return true;
  }

  /***********************************
   * 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("holderName", getHolderName());
    return obj;
  }

}