diff options
author | aclement <aclement> | 2004-08-06 12:30:09 +0000 |
---|---|---|
committer | aclement <aclement> | 2004-08-06 12:30:09 +0000 |
commit | 0b2c06e92277f4ab5be9d5d73fbc5af4184977fc (patch) | |
tree | 8f2b341fabe745d5237c8814acaf2ba5bf96ecff /tests/incremental/model/introduction/changes/Point.30.java | |
parent | 75111669c8de9717a3d5c37954cbcc48fd64300b (diff) | |
download | aspectj-0b2c06e92277f4ab5be9d5d73fbc5af4184977fc.tar.gz aspectj-0b2c06e92277f4ab5be9d5d73fbc5af4184977fc.zip |
Moved around to fit in with new way of executing the incremental model tests as junit tests.
Diffstat (limited to 'tests/incremental/model/introduction/changes/Point.30.java')
-rw-r--r-- | tests/incremental/model/introduction/changes/Point.30.java | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/tests/incremental/model/introduction/changes/Point.30.java b/tests/incremental/model/introduction/changes/Point.30.java new file mode 100644 index 000000000..609a0488c --- /dev/null +++ b/tests/incremental/model/introduction/changes/Point.30.java @@ -0,0 +1,98 @@ +/* + Copyright (c) Xerox Corporation 1998-2002. All rights reserved. + + Use and copying of this software and preparation of derivative works based + upon this software are permitted. Any distribution of this software or + derivative works must comply with all applicable United States export control + laws. + + This software is made available AS IS, and Xerox Corporation makes no warranty + about the software, its performance or its conformity to any specification. +*/ + +package introduction; + +public class Point { + + protected double x = 0; + protected double y = 0; + protected double theta = 0; + protected double rho = 0; + + protected boolean polar = true; + protected boolean rectangular = true; + + public double getX(){ + makeRectangular(); + return x; + } + + public double getY(){ + makeRectangular(); + return y; + } + + public double getTheta(){ + makePolar(); + return theta; + } + + public double getRho(){ + makePolar(); + return rho; + } + + public void setRectangular(double newX, double newY){ + x = newX; + y = newY; + rectangular = true; + polar = false; + } + + public void setPolar(double newTheta, double newRho){ + theta = newTheta; + rho = newRho; + rectangular = false; + polar = true; + } + + public void rotate(double angle){ + setPolar(theta + angle, rho); + } + + public void offset(double deltaX, double deltaY){ + setRectangular(x + deltaX, y + deltaY); + } + + protected void makePolar(){ + if (!polar){ + theta = Math.atan2(y,x); + rho = y / Math.sin(theta); + polar = true; + } + } + + protected void makeRectangular(){ + if (!rectangular) { + x = rho * Math.sin(theta); + y = rho * Math.cos(theta); + rectangular = true; + } + } + + public String toString(){ + return "(" + getX() + ", " + getY() + ")[" + + getTheta() + " : " + getRho() + "]"; + } + + public static void main(String[] args){ + Point p1 = new Point(); + System.out.println("p1 =" + p1); + p1.setRectangular(5,2); + System.out.println("p1 =" + p1); + p1.setPolar( Math.PI / 4.0 , 1.0); + System.out.println("p1 =" + p1); + p1.setPolar( 0.3805 , 5.385); + System.out.println("p1 =" + p1); + } +} |