/*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 java.sql.Date;
import BankingSystem.*;
import BankingSystem.json.*;

public class Cheque extends FinancialInstrument {
  //Class datatypes
  private String amount;

  private Date date;

  private String sequenceNumber;

  //Class association variables
  private BankAccount bankAccount;

  //Registry of our system.
  BankingSystemRegistry registry = BankingSystemRegistry.getInstance();

  //Constructor
  public Cheque(String aAmount, Date aDate, String aSequenceNumber,
    BankAccount aBankAccount) {
    super();
    amount = aAmount;
    date = aDate;
    sequenceNumber = aSequenceNumber;
    bankAccount = aBankAccount;
    bankAccount.addCheque(this);

  }

  public boolean setAmount(String aAmount) {
    amount = aAmount;
    return true;
  }

  public boolean setDate(Date aDate) {
    date = aDate;
    return true;
  }

  public boolean setSequenceNumber(String aSequenceNumber) {
    sequenceNumber = aSequenceNumber;
    return true;
  }

  public String getAmount() {
    return amount;
  }

  public Date getDate() {
    return date;
  }

  public String getSequenceNumber() {
    return sequenceNumber;
  }

  public BankAccount getBankAccount() {
    return bankAccount;
  }

  /* This class does not drive BankAccount and therefore sets the association unidirectionally.*/
  public void setBankAccount(BankAccount aBankAccount) {
    bankAccount = aBankAccount;
  }

  public void delete() {
    //Delete all 1 ends.
    bankAccount.deleteCheque(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("amount", getAmount());
    obj.put("date", getDate());
    obj.put("sequenceNumber", getSequenceNumber());
    return obj;
  }

}