Commit | Line | Data |
---|---|---|
0f30f194 | 1 | #!/usr/bin/perl |
2 | ||
5b1aeb78 | 3 | package Plain::Point; |
0f30f194 | 4 | |
5 | use strict; | |
6 | use warnings; | |
7 | ||
8 | sub new { | |
9 | my ( $class, %params ) = @_; | |
10 | ||
11 | return bless { | |
c0cbf4d9 | 12 | x => $params{x} || 10, |
0f30f194 | 13 | y => $params{y}, |
14 | }, $class; | |
15 | } | |
16 | ||
17 | sub x { | |
18 | my ( $self, @args ) = @_; | |
19 | ||
20 | if ( @args ) { | |
21 | $self->{x} = $args[0]; | |
22 | } | |
23 | ||
24 | return $self->{x}; | |
25 | } | |
26 | ||
27 | sub y { | |
28 | my ( $self, @args ) = @_; | |
29 | ||
30 | if ( @args ) { | |
31 | $self->{y} = $args[0]; | |
32 | } | |
33 | ||
34 | return $self->{y}; | |
35 | } | |
36 | ||
37 | sub clear { | |
38 | my $self = shift; | |
b07c7a9d | 39 | @{$self}{qw/x y/} = (0, 0); |
0f30f194 | 40 | } |
41 | ||
42 | __PACKAGE__; | |
43 | ||
44 | __END__ | |
45 |