JML

org.jmlspecs.samples.dbc
Class Rectangular

java.lang.Object
  extended byorg.jmlspecs.samples.dbc.ComplexOps
      extended byorg.jmlspecs.samples.dbc.Rectangular
All Implemented Interfaces:
Complex

public strictfp class Rectangular
extends ComplexOps

Complex numbers in rectangular coordinates.

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

Field Summary
private  double img
          The imaginary part of this number.
private  double re
          The real part of this number.
 
Constructor Summary
Rectangular()
          Initialize this Complex number to be 0+(0*i).
Rectangular(double re)
          Initialize this Complex number to be re+(0*i).
Rectangular(double re, double img)
          Initialize this Complex number to be re+(img*i).
 
Method Summary
 double angle()
          Return the angle of this complex number.
 double imaginaryPart()
          Return the imaginary part of this complex number.
 double magnitude()
          Return the magnitude of this complex number.
 double realPart()
          Return the real part of this complex number.
 String toString()
           
 
Methods inherited from class org.jmlspecs.samples.dbc.ComplexOps
add, div, equals, hashCode, mul, sub
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

re

private double re
The real part of this number.


img

private double img
The imaginary part of this number.

Constructor Detail

Rectangular

public Rectangular()
Initialize this Complex number to be 0+(0*i).


Rectangular

public Rectangular(double re)
Initialize this Complex number to be re+(0*i).


Rectangular

public Rectangular(double re,
                   double img)
Initialize this Complex number to be re+(img*i).

Method Detail

realPart

public double realPart()
Description copied from interface: Complex
Return the real part of this complex number.


imaginaryPart

public double imaginaryPart()
Description copied from interface: Complex
Return the imaginary part of this complex number.


magnitude

public double magnitude()
Description copied from interface: Complex
Return the magnitude of this complex number.


angle

public double angle()
Description copied from interface: Complex
Return the angle of this complex number.


toString

public String toString()
Overrides:
toString 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.