📄 material.java
字号:
/*
* Material.java E.L. 2001-08-17
*
*/
import java.text.*;
abstract class Material {
private String name; // identifies the material
private double price; // price per unit
/* These two formats are used in toString() methods */
protected static final DecimalFormat decimalFormat = new DecimalFormat("####0.00");
protected static final NumberFormat currencyFormat = NumberFormat.getCurrencyInstance();
public Material(String initName, double initPrice) {
name = initName;
price = initPrice;
}
public String getName() {
return name;
}
public double getPricePerUnit() {
return price;
}
public double getTotalPrice(Surface aSurface) {
return getMaterialReq(aSurface) * price;
}
public abstract double getMaterialReq(Surface aSurface);
public String toString() {
return getClass().getName() + ": " + name + ", price " + currencyFormat.format(price);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -