From: Scott H. <sco...@us...> - 2005-05-16 22:59:20
|
Update of /cvsroot/actionstep/actionstep/src/org/actionstep In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13868/src/org/actionstep Modified Files: NSPoint.as Log Message: Added add() and subtract() static methods Filled in comments Index: NSPoint.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSPoint.as,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** NSPoint.as 4 May 2005 02:33:05 -0000 1.1.1.1 --- NSPoint.as 16 May 2005 22:57:08 -0000 1.2 *************** *** 31,53 **** import org.actionstep.NSObject; class org.actionstep.NSPoint extends NSObject { public static var ZeroPoint = new NSPoint(0,0); public var x:Number; public var y:Number; public function NSPoint(x:Number, y:Number) { this.x = x; this.y = y; } ! public function clone():NSPoint { return new NSPoint(x, y); } public function description():String { return "NSPoint(x="+x+", y="+y+")"; } } \ No newline at end of file --- 31,85 ---- import org.actionstep.NSObject; + /** + * Represents a point in 2D space. Contains an x-coordinate and a y-coordinate. + */ class org.actionstep.NSPoint extends NSObject { + /** A point with location (0, 0). */ public static var ZeroPoint = new NSPoint(0,0); + /** The x-coordinate. */ public var x:Number; + + /** The y-coordinate. */ public var y:Number; + /** + * Creates a new instance of NSPoint with the specified x and y + * coordinates. + */ public function NSPoint(x:Number, y:Number) { this.x = x; this.y = y; } ! ! /** ! * Creates a new point with the same properties as this one. ! */ public function clone():NSPoint { return new NSPoint(x, y); } + /** + * @see org.actionstep.NSObject#description + */ public function description():String { return "NSPoint(x="+x+", y="+y+")"; } + /** + * Adds point1 to point2 and returns the result. + */ + public static function add(point1:NSPoint, point2:NSPoint):NSPoint + { + return new NSPoint(point2.x + point1.x, point2.y + point1.y); + } + + /** + * Subtracts point2 from point1 and returns the result. + */ + public static function subtract(point1:NSPoint, point2:NSPoint):NSPoint + { + return new NSPoint(point2.x - point1.x, point2.y - point1.y); + } } \ No newline at end of file |