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

📄 surface.java

📁 Java the UML Way 书中所有源码
💻 JAVA
字号:
/*
 * Surface.java   E.L. 2001-08-15
 *
 */
class Surface {
  private String name;  // for identification purposes
  private double length;
  private double width;
  private Material material;

  /*
   * Material is not an argument to the constructor. It should be allowed to create
   * Surface objects without at the same time decide which material is prefered.
   * Material may be set by the method setmaterial().
   */
  public Surface(String initName, double initLength, double initWidth) {
    name = initName;
    length = initLength;
    width = initWidth;
  }

  public String getName() {
    return name;
  }

  public double getLength() {
    return length;
  }

  public double getWidth() {
    return width;
  }

  public Material getMaterial() {  // returns null if material is not registered
    return material;
  }

  public void setMaterial(Material newMaterial) {
    material = newMaterial;
  }

  public double getArea() {
    return width * length;
  }

  public double getCircumference() {
    return 2 * (length + width);
  }
}

⌨️ 快捷键说明

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