⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nonprofitcorporation.java

📁 此程序都是企业级 的数据库开发程序 全面揭示了JAVA对数据库的操作
💻 JAVA
字号:
import java.util.*;

import org.jlf.log.*;
import org.jlf.dataMap.*;

/**
 * This class hold information for a non-profit corporate
 * customer to give volume discounts for their purchases
 * and also not charge them sales tax.
 */
public class NonProfitCorporation extends Corporation {

  // --------------------------------------------------------------
  // Section 1: DataMappedObject descriptors
  // --------------------------------------------------------------

  // Constants for attributes
  public static final String TAX_EXEMPT_ID_ATTRIBUTE = "TAX_EXEMPT_ID";

  /**
   * Adds attribute descriptors for the current class.
   */
  protected Hashtable basicGetAttributeDescriptors() {

    // Always call the superclass!
    Hashtable descriptors = super.basicGetAttributeDescriptors();
    DataAttributeDescriptor descriptor;

    // Then add class-specific attributes
    descriptor = new DataAttributeDescriptor(TAX_EXEMPT_ID_ATTRIBUTE, 
                                             StringAttribute.class, false);
    descriptor.setMaximumLength(50);
    descriptors.put(TAX_EXEMPT_ID_ATTRIBUTE, descriptor);

    return descriptors;
  } 

  /**
   * Default constructor must be public for the data mapping
   * framework!  However, when creating a new object, look to use
   * a paramterized constructor.
   */
  public NonProfitCorporation() {}


  // --------------------------------------------------------------
  // Section 2: Java bean and business logic methods
  // --------------------------------------------------------------

  /**
   * Main constructor for the class.  Populates all
   * attributes of the class and sets the type accordingly.
   */
  public NonProfitCorporation(String nickname, String emailAddress, 
                              String name, String companyName, 
                              String address, String city, String state, 
                              String zipcode, String taxExemptId) {
    super(nickname, emailAddress, name, companyName, address, city, state, 
          zipcode);
    setTaxExemptId(taxExemptId);
    resetCustomerType(CustomerType.NON_PROFIT_CUSTOMER);
  }

  /**
   * Retrieves the tax exempt id.
   */
  public String getTaxExemptId() {
    return getStringAttribute(TAX_EXEMPT_ID_ATTRIBUTE);
  } 

  /**
   * Sets the tax exempt id.
   */
  public void setTaxExemptId(String id) {
    setStringAttribute(TAX_EXEMPT_ID_ATTRIBUTE, id);
  } 

  /**
   * Return the amount of discount applicable to the volume
   * customer.  Give a 15% discount to all non-profit groups.
   */
  public double discountRate() {
    return 0.15;
  } 

  /**
   * This customer is a non-profit corporation.
   */
  public boolean isNonProfit() {
    return true;
  } 

  /**
   * Add to superclass to output additional
   * volume customer attributes
   */
  public String toString() {
    return super.toString() + "\n  Tax Exempt Id: " + getTaxExemptId();
  } 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -