Playing cards: Difference between revisions

→‎{{header|Perl 6}}: "multi prefix:<~>" → "method Str". This change makes it possible to privatize the instance variables, so I did.
(Added Perl 6.)
(→‎{{header|Perl 6}}: "multi prefix:<~>" → "method Str". This change makes it possible to privatize the instance variables, so I did.)
Line 1,369:
 
class Card {
has Pip $.!pip;
has Suit $.!suit;
 
multi prefix:<~> (Card $c) method Str { $c.!pip.name ~ " of " ~ $c.!suit.name }
}
 
multi prefix:<~> (Card $c) { $c.pip.name ~ " of " ~ $c.suit.name }
 
class Deck {
has Card @.!cards;
submethod BUILD {
Line 1,387:
 
method deal { shift @!cards }
}
 
multi prefix:<~> (Deck $d) method Str { join ', ', map ~*, $d.@!cards }</lang>
}</lang>
 
Some examples of use:
845

edits