BankAccount的接口规范包含一个类范围的不变条件测试,即余额总要大于或等于0(对不起,不允许透支)。
The contract specification for BankAccount includes a class-wide invariant that the balance must always be greater than or equal to zero (sorry, no overdrafts allowed!).
上一期中使用到的其他类保持不变。
OVal并不是惟一可用的dbc库,事实上其DBC结构对比其他框架来说是相当有限的(例如,它未提供指定类不变式的简易方法)。
OVal isn't the only DBC library available, and in fact its DBC constructs are fairly limiting compared to other frameworks (for example, it doesn't offer an easy way to specify class invariants).
应用推荐