/*This code was generated using the UMPLE modeling language!
 Date of generation: 2008/07/30 12:41:46*/
/*This class drives: */

package BankingSystem.core;

import BankingSystem.*;
import BankingSystem.json.*;

public class ReusableFinancialInstrument extends FinancialInstrument {
  //Class datatypes
  private String number;

  private String PIN;

  //Class association variables
  private FinancialInstitution financialInstitution;

  private Currency currency;

  //Registry of our system.
  BankingSystemRegistry registry = BankingSystemRegistry.getInstance();

  //Constructor
  public ReusableFinancialInstrument(String aNumber, String aPIN,
    FinancialInstitution aFinancialInstitution, Currency aCurrency) {
    super();
    number = aNumber;
    PIN = aPIN;
    financialInstitution = aFinancialInstitution;
    financialInstitution.addReusableFinancialInstrument(this);

    currency = aCurrency;

  }

  public boolean setNumber(String aNumber) {
    number = aNumber;
    return true;
  }

  public boolean setPIN(String aPIN) {
    PIN = aPIN;
    return true;
  }

  public String getNumber() {
    return number;
  }

  public String getPIN() {
    return PIN;
  }

  public FinancialInstitution getFinancialInstitution() {
    return financialInstitution;
  }

  public Currency getCurrency() {
    return currency;
  }

  /* This class does not drive FinancialInstitution and therefore sets the association unidirectionally.*/
  public void setFinancialInstitution(FinancialInstitution aFinancialInstitution) {
    financialInstitution = aFinancialInstitution;
  }

  /* This class does not drive Currency and therefore sets the association unidirectionally.*/
  public void setCurrency(Currency aCurrency) {
    currency = aCurrency;
  }

  public void delete() {
    //Delete all 1 ends.
    financialInstitution.deleteReusableFinancialInstrument(this);
  }

  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("number", getNumber());
    obj.put("PIN", getPIN());
    return obj;
  }

}