Last active
August 29, 2015 14:22
-
-
Save jshbrntt/5ba0332ff27ebf91c98a to your computer and use it in GitHub Desktop.
Point Class in TypeScript, ActionScript, and Java Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TypeScript | |
class Point | |
{ | |
public x: number; | |
public y: number; | |
constructor(x:number = 0.0, y:number = 0.0) | |
{ | |
this.x = x; | |
this.y = y; | |
} | |
public add(point: Point): Point | |
{ | |
return new Point(this.x + point.x, this.y + point.y); | |
} | |
} | |
// ActionScript 3 (Flash) | |
package | |
{ | |
public class Point | |
{ | |
public var x:Number; | |
public var y:Number; | |
public function Point(x:Number = 0.0, y:Number = 0.0) | |
{ | |
this.x = x; | |
this.y = y; | |
} | |
public function add(point:Number):Point | |
{ | |
return new Point(this.x + point.x, this.y + point.y); | |
} | |
} | |
} | |
// Java | |
public class Point | |
{ | |
public double x; | |
public double y; | |
public Point(double x, double y) | |
{ | |
this.x = x; | |
this.y = y; | |
} | |
public Point add(Point point) { | |
return new Point(this.x + point.x, this.y + point.y); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment