Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2021
69
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Line is export {
  2. has Point $.a;
  3. has Point $.b;
  4. has Int $.int-motif is rw = 43;
  5. has Str $.motif;
  6.  
  7. submethod BUILD(:$!a,:$!b,:$!motif){}
  8. method new(
  9. $a where (all(@$a) ~~ Int and $a.elems == 2),
  10. $b where (all(@$b) ~~ Int and $b.elems == 2),:$int-motif? ) {
  11. my ($imotif,$motif);
  12. if not defined $int-motif {
  13. $imotif = 43;
  14. } else {
  15. $imotif = $int-motif;
  16. }
  17. $motif = chr($imotif);
  18. self.bless(
  19. a => Point.new($a[0],$a[1]),
  20. b => Point.new($b[0],$b[1]),
  21. int-motif => $imotif,
  22. motif => $motif
  23. );
  24. }
  25.  
  26.  
  27. method test {
  28. say $!a;
  29. say $!b;
  30. say $!motif;
  31. }
  32. }
  33.  
Advertisement
RAW Paste Data Copied
Advertisement