📄 parcel.java
字号:
//Figure 8.2public class Parcel { public double weight; public double volume; public boolean isAirFreight; /** post: weight==w and volume==v and isAirFreight==b */ public Parcel( double w, double v, boolean b) { weight = w; volume = v; isAirFreight = b; } /** post: isAirFreight implies * result == cost to ship as air freight. * and !isAirFreight implies * result == cost to ship by truck. */ public double shippingCost() { double cost; if (isAirFreight) if (weight > 1.0) cost = 15 + 2.75 * weight + 6 * (volume-1); else cost = 15 + weight * 2.75; else // !isAirFreight cost = 5 + 0.04 * weight; return cost; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -