# Copyright (c) 2023 Yuki Kimoto
# MIT License
class Point3D extends Point {
version_from SPVM;
# Fields
has z : ro int;
# Class method
static method new : Point3D ($x : int = 0, $y : int = 0, $z : int = 0) {
my $self = new Point3D;
$self->init($x, $y, $z);
return $self;
}
protected method init : Point3D ($x : int = 0, $y : int = 0, $z : int = 0) {
$self->SUPER::init($x, $y);
$self->{z} = $z;
}
method clear : void () {
$self->SUPER::clear;
$self->{z} = 0;
}
method clone : Point3D () {
my $self_clone = Point3D->new($self->x, $self->y, $self->z);
return $self_clone;
}
method to_string : string () {
my $x = $self->x;
my $y = $self->y;
my $z = $self->z;
my $string = "($x,$y,$z)";
return $string;
}
method eq : int ($a : Point3D, $b : Point3D) {
my $eq = 0;
if ($a && $b) {
if ($a->{x} == $b->{x} && $a->{y} == $b->{y} && $a->{z} == $b->{z}) {
$eq = 1;
}
}
elsif ($a) {
$eq = 0;
}
elsif ($b) {
$eq = 0;
}
else {
$eq = 1;
}
return $eq;
}
}