Go Fish/D: Difference between revisions
m
Fixed syntax highlighting.
(Updated comments) |
m (Fixed syntax highlighting.) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 4:
In D strings are only partially reference types, unlike in Python, so I have used a small class to keep the shared deck. I have also used an abstract class to simplify and reduce the code compared to the Python entry that has some code duplication.
<
std.algorithm
class EndGameException : Exception {
Line 97 ⟶ 95:
/// Displays current hand, cards separated by spaces.
string displayHand() {
//return
return hand.byKey.map!(k => [k].replicate(hand[k]))
}
Line 227 ⟶ 222:
} catch (EndGameException)
writeln("Game finished.");
}</
|