Skip to content

Instantly share code, notes, and snippets.

@jshbrntt
Last active August 29, 2015 14:22
Show Gist options
  • Save jshbrntt/5ba0332ff27ebf91c98a to your computer and use it in GitHub Desktop.
Save jshbrntt/5ba0332ff27ebf91c98a to your computer and use it in GitHub Desktop.
Point Class in TypeScript, ActionScript, and Java Example
// 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