📄 flooring2.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 + -