JML

org.jmlspecs.samples.dbc
Class ComplexOps

java.lang.Object
  extended byorg.jmlspecs.samples.dbc.ComplexOps
All Implemented Interfaces:
Complex
Direct Known Subclasses:
Polar, Rectangular

public abstract strictfp class ComplexOps
extends Object
implements Complex

An abstract class that holds all of the common algorithms for complex numbers. Note that this class knows about both of its subclasses Rectangular and Polar.

Author:
Gary T. Leavens with help from Abelson and Sussman's Structure and Interpretation of Computer Programs

Constructor Summary
ComplexOps()
           
 
Method Summary
 Complex add(Complex b)
          Return this + b (the sum of this and b).
 Complex div(Complex b)
          Return this/b (the quotient of this by b).
 boolean equals(Object o)
          Return true if these are the same complex number.
 int hashCode()
          Return a hashCode for this number.
 Complex mul(Complex b)
          Tell whether the given angles are the same, taking into account that angles measured in radians wrap around after 2*StrictMath.PI times.
 Complex sub(Complex b)
          Return this - b (the difference between this and b).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jmlspecs.samples.dbc.Complex
angle, imaginaryPart, magnitude, realPart
 

Constructor Detail

ComplexOps

public ComplexOps()
Method Detail

add

public Complex add(Complex b)
Description copied from interface: Complex
Return this + b (the sum of this and b).

Specified by:
add in interface Complex

sub

public Complex sub(Complex b)
Description copied from interface: Complex
Return this - b (the difference between this and b).

Specified by:
sub in interface Complex

mul

public Complex mul(Complex b)
Description copied from interface: Complex
Tell whether the given angles are the same, taking into account that angles measured in radians wrap around after 2*StrictMath.PI times. Return the positive remainder of n divided by d. Return this * b (the product of this and b).

Specified by:
mul in interface Complex

div

public Complex div(Complex b)
Description copied from interface: Complex
Return this/b (the quotient of this by b).

Specified by:
div in interface Complex

equals

public boolean equals(Object o)
Description copied from interface: Complex
Return true if these are the same complex number.

Specified by:
equals in interface Complex
Overrides:
equals in class Object

hashCode

public int hashCode()
Description copied from interface: Complex
Return a hashCode for this number.

Specified by:
hashCode in interface Complex
Overrides:
hashCode in class Object

JML

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.