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

📄 merchandise.java

📁 Java the UML Way 书中所有源码
💻 JAVA
字号:
/*
 * Merchandise.java   E.L. 1999-10-27 (2000-10-14, english version)
 * Is to be used in exercises, chapter 10.
 *
 */
class Merchandise {
  private static final double VAT = 23.0;
  private static final double VATfactor = 1.0 + VAT / 100.0;

  private String merchandiseName;
  private int merchandiseNo;
  private double price; // price a kilo, without VAT

  public Merchandise(String initMerchandiseName, int initMerchandiseNo, double initPrice) {
    merchandiseName = initMerchandiseName;
    merchandiseNo = initMerchandiseNo;
    price = initPrice;
  }

  public Merchandise(String initMerchandiseName, int initMerchandiseNo) {
    merchandiseName = initMerchandiseName;
    merchandiseNo = initMerchandiseNo;
    price = 0.0;
  }

  public double getPriceWithoutVAT(double noKilo) {
    return price * noKilo;
  }

  public double getPriceWithVAT(double noKilo) {
    return price * noKilo * VATfactor;
  }

  public void setPrice(double newPrice) {
    price = newPrice;
  }
}

⌨️ 快捷键说明

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