org.jmlspecs.samples.prelimdesign
Class USMoney
java.lang.Object
org.jmlspecs.samples.prelimdesign.MoneyAC
org.jmlspecs.samples.prelimdesign.MoneyComparableAC
org.jmlspecs.samples.prelimdesign.USMoney
- All Implemented Interfaces:
- Cloneable, JMLType, Money, MoneyComparable, MoneyOps, Serializable
- public class USMoney
- extends MoneyComparableAC
- implements MoneyOps
Specifications inherited from class MoneyAC |
protected constraint_redundantly this.numCents == \old(this.numCents);
protected represents pennies <- this.numCents; |
Specifications inherited from class Object |
represents objectState <- org.jmlspecs.lang.JMLDataGroup.IT;
public represents _getClass <- \typeof(this); |
Specifications inherited from interface Money |
instance public constraint this.pennies == \old(this.pennies); |
Model fields inherited from interface org.jmlspecs.samples.prelimdesign.Money |
pennies |
Fields inherited from class org.jmlspecs.samples.prelimdesign.MoneyAC |
numCents |
USMoney
public USMoney(long cs)
- Specifications: (class)pure
-
public normal_behavior
assignable pennies;
ensures this.pennies == cs;
- implies_that
-
protected normal_behavior
assignable pennies, numCents;
ensures this.numCents == cs;
USMoney
public USMoney(double amt)
- Specifications: (class)pure
-
public normal_behavior
assignable pennies;
ensures this.pennies == (long)(100.0*amt);
plus
public MoneyOps plus(Money m2)
- Specified by:
plus
in interface MoneyOps
- Specifications: (class)pure
- Specifications inherited from overridden method plus(Money m2) in interface MoneyOps:
(class)pure -
public normal_behavior
old boolean can_add = this.can_add(m2);
requires m2 != null&&can_add;
assignable \nothing;
ensures \result != null&&\result .pennies == this.pennies+m2.pennies;
- for_example
-
public normal_example
requires this.pennies == 300&&m2.pennies == 400;
assignable \nothing;
ensures \result != null&&\result .pennies == 700;
minus
public MoneyOps minus(Money m2)
- Specified by:
minus
in interface MoneyOps
- Specifications: (class)pure
- Specifications inherited from overridden method minus(Money m2) in interface MoneyOps:
(class)pure -
public normal_behavior
old boolean inRange = this.inRange(this.pennies-m2.pennies);
requires m2 != null&&inRange;
assignable \nothing;
ensures \result != null&&\result .pennies == this.pennies-m2.pennies;
- for_example
-
public normal_example
requires this.pennies == 400&&m2.pennies == 300;
assignable \nothing;
ensures \result != null&&\result .pennies == 100;
scaleBy
public MoneyOps scaleBy(double factor)
- Specified by:
scaleBy
in interface MoneyOps
- Specifications: (class)pure
- Specifications inherited from overridden method scaleBy(double factor) in interface MoneyOps:
(class)pure -
public normal_behavior
requires this.can_scaleBy(factor);
assignable \nothing;
ensures \result != null&&\result .pennies == (long)(factor*this.pennies);
- for_example
-
public normal_example
requires this.pennies == 400&&factor == 1.01;
assignable \nothing;
ensures \result != null&&\result .pennies == 404;
toString
public String toString()
- Overrides:
toString
in class Object
- Specifications: (class)pure
- Specifications inherited from overridden method in class Object:
non_null -
public normal_behavior
assignable objectState;
ensures \result != null&&\result .equals(this.theString);
ensures (* \result is a string representation of this object *);
- also
-
public code normal_behavior
assignable \nothing;
ensures \result != null&&(* \result is the instance's class name, followed by an @, followed by the instance's hashcode in hex *);
- also
-
public code model_program { ... }
- implies_that
-
assignable objectState;
ensures \result != null;
JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.