summaryrefslogtreecommitdiff
path: root/tutorial/examples/rtrefl/Point.oj
blob: e15b6072abf732b262ccddef0475cda13f5171f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * Point.oj
 */
package examples.rtrefl;


public class Point instantiates RTReflClass
{
    public int x, y;
    public String name;

    public Point( String name, int x, int y ) {
    this.x = x;
    this.y = y;
    this.name = name;
    }

    public Point( int x, int y ) {
    this( "DefaultName", x, y );
    }

    public String toString() {
    return "(" + x + "," + y + ")";
    }

    public void move( int dx, int dy ) {
    x += dx;
    y += dy;
    }

    public double distanceFromOrigin() {
    return Math.sqrt( (double) x * x + y * y );
    }

}