/*This code was generated using the UMPLE modeling language!
 Date of generation: 2008/07/30 10:46:16*/
/*This class drives: */

package hotel.core;

import java.sql.Time;
import hotel.*;
import hotel.json.*;

public class ItemOnBill {
  //Class datatypes
  private String description;

  private String charge;

  //Class association variables
  private Booking booking;

  //Registry of our system.
  HotelRegistry registry = HotelRegistry.getInstance();

  //Constructor
  public ItemOnBill(String aDescription, String aCharge, Booking aBooking) {
    description = aDescription;
    charge = aCharge;
    booking = aBooking;
    booking.addItemOnBill(this);

  }

  public boolean setDescription(String aDescription) {
    description = aDescription;
    return true;
  }

  public boolean setCharge(String aCharge) {
    charge = aCharge;
    return true;
  }

  public String getDescription() {
    return description;
  }

  public String getCharge() {
    return charge;
  }

  public Booking getBooking() {
    return booking;
  }

  /* This class does not drive Booking and therefore sets the association unidirectionally.*/
  public void setBooking(Booking aBooking) {
    booking = aBooking;
  }

  public void delete() {
    //Delete all 1 ends.
    booking.deleteItemOnBill(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("description", getDescription());
    obj.put("charge", getCharge());
    return obj;
  }

}