| 1 | package SPVM::Point; | ||
| 2 | |||
| 3 | 1; | ||
| 4 | |||
| 5 | =head1 Name | ||
| 6 | |||
| 7 | SPVM::Point - Point | ||
| 8 | |||
| 9 | =head1 Usage | ||
| 10 | |||
| 11 | use Point; | ||
| 12 | |||
| 13 | my $point = Point->new; | ||
| 14 | my $point = Point->new(1, 2); | ||
| 15 | |||
| 16 | my $x = $point->x; | ||
| 17 | my $y = $point->y; | ||
| 18 | |||
| 19 | my $point_string = $point->to_string; | ||
| 20 | |||
| 21 | =head1 Description | ||
| 22 | |||
| 23 | C<Point> is a class for a point. | ||
| 24 | |||
| 25 | =head1 Interfaces | ||
| 26 | |||
| 27 | C<Point> class has the following interfaces. | ||
| 28 | |||
| 29 | =over 2 | ||
| 30 | |||
| 31 | =item * L<Stringable|SPVM::Stringable> | ||
| 32 | |||
| 33 | =item * L<Cloneable|SPVM::Cloneable> | ||
| 34 | |||
| 35 | =item * L<EqualityCheckable|SPVM::EqualityCheckable> | ||
| 36 | |||
| 37 | =back | ||
| 38 | |||
| 39 | =head1 Fields | ||
| 40 | |||
| 41 | =head2 x | ||
| 42 | |||
| 43 | has x : protected ro int; | ||
| 44 | |||
| 45 | C<x>. | ||
| 46 | |||
| 47 | =head2 y | ||
| 48 | |||
| 49 | has y : protected ro int; | ||
| 50 | |||
| 51 | C<y>. | ||
| 52 | |||
| 53 | =head1 Class Methods | ||
| 54 | |||
| 55 | =head2 new | ||
| 56 | |||
| 57 | C<static method new : L<Point|SPVM::Point> ($x : int = 0, $y : int = 0);> | ||
| 58 | |||
| 59 | Create a new C<Point> object with $x and $y. | ||
| 60 | |||
| 61 | =head1 Instance Methods | ||
| 62 | |||
| 63 | =head2 init | ||
| 64 | |||
| 65 | protected method init : Point ($x : int = 0, $y : int = 0) | ||
| 66 | |||
| 67 | Initializes L</"x"> and L</"y">. | ||
| 68 | |||
| 69 | =head2 clear | ||
| 70 | |||
| 71 | C<method clear : void ();> | ||
| 72 | |||
| 73 | Sets L</"x"> and L</"y"> to 0. | ||
| 74 | |||
| 75 | =head2 clone | ||
| 76 | |||
| 77 | C<method clone : L<Point|SPVM::Point> ();> | ||
| 78 | |||
| 79 | Creates a new C<Point> object that clones myself. | ||
| 80 | |||
| 81 | =head2 to_string | ||
| 82 | |||
| 83 | C<method to_string : string ();> | ||
| 84 | |||
| 85 | Stringifies C<Point> object as the following format. | ||
| 86 | |||
| 87 | (1,2) | ||
| 88 | |||
| 89 | C<method eq : int ($a : Point, $b : Point);> | ||
| 90 | |||
| 91 | If $a is equal to $b, returns 1, otherwise returns 0. | ||
| 92 | |||
| 93 | Implementation: | ||
| 94 | |||
| 95 | If $a and $b is defined and L</"x">, L</"y">, and L</"z"> fields in $a are equals to L</"x">, L</"y">, and L</"z"> fields in $b, returns 1. | ||
| 96 | |||
| 97 | If only $a is not defined, returns 0. | ||
| 98 | |||
| 99 | If only $b is not defined, returns 0. | ||
| 100 | |||
| 101 | If both $a and $b is not defined, returns 1. | ||
| 102 | |||
| 103 | =head1 Copyright & License | ||
| 104 | |||
| 105 | Copyright (c) 2023 Yuki Kimoto | ||
| 106 | |||
| 107 | MIT License |