class Point {
# Interfaces
interface Stringable;
interface Cloneable;
# Fields
has x : rw int;
has y : rw int;
# Class methods
static method new : Point () {
return new Point;
}
static method new_xy : Point ($x : int, $y : int) {
my $self = Point->new;
$self->set_x($x);
$self->set_y($y);
return $self;
}
# Instance methods
method clear : void () {
$self->{x} = 0;
$self->{y} = 0;
}
method cloneable_clone : object () {
my $self_clone = Point->new_xy($self->x, $self->y);
return $self_clone;
}
method to_string : string () {
my $x = $self->x;
my $y = $self->y;
my $string = "($x,$y)";
return $string;
}
}