Anonymous user
Playing cards: Difference between revisions
m
→Kotlin/object-oriented: private companion
(→{{header|Kotlin}}: class version) |
m (→Kotlin/object-oriented: private companion) |
||
Line 3,364:
=== object-oriented ===
<lang scala>class Deck : ArrayList<String> {
constructor() { FACES.forEach { face -> SUITS.forEach { add("$face$it") } } }
constructor(c: Collection<String>) { addAll(c) }▼
▲ constructor(c: Collection<String>) {
fun dealTop(n: Int) = Deck(take(n))
Line 3,382 ⟶ 3,377:
}
private companion object {
const val FACES = "23456789TJQKA"
const val SUITS = "shdc"
|