Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Line is export {
- has Point $.a;
- has Point $.b;
- has Int $.int-motif is rw = 43;
- has Str $.motif;
- submethod BUILD(:$!a,:$!b,:$!motif){}
- method new(
- $a where (all(@$a) ~~ Int and $a.elems == 2),
- $b where (all(@$b) ~~ Int and $b.elems == 2),:$int-motif? ) {
- my ($imotif,$motif);
- if not defined $int-motif {
- $imotif = 43;
- } else {
- $imotif = $int-motif;
- }
- $motif = chr($imotif);
- self.bless(
- a => Point.new($a[0],$a[1]),
- b => Point.new($b[0],$b[1]),
- int-motif => $imotif,
- motif => $motif
- );
- }
- method test {
- say $!a;
- say $!b;
- say $!motif;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment