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

📄 flooring2.java

📁 Java the UML Way 书中所有源码
💻 JAVA
字号:
/*
 * Flooring2.java   E.L. 2001-08-18
 *
 */

abstract class Flooring2 extends Material {
  private static final double limit = 0.02; // limit for one more width
  private double widthOfFlooring;    // meter 
  /*
   * This class is abstract, and so it is not possible to create instances of the class.
   * The constructor is needed in subclasses.
   */
  protected Flooring2(String initName, double initPrice, double initWidth) {
    super(initName, initPrice);
    widthOfFlooring = initWidth;
  }

  public final double getWidth() {
    return widthOfFlooring;
  }
  
  public double getMaterialReq(Surface aSurface) {
    double lengthSurface = aSurface.getLength();
    double widthSurface = aSurface.getWidth();

    int noOfWidths = (int)(lengthSurface / widthOfFlooring);
    double rest = lengthSurface % widthOfFlooring;
    if (rest >= limit) noOfWidths++;
    return noOfWidths * widthSurface;
  }  
}

⌨️ 快捷键说明

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