Use NamedTuple; Fix camelCase->snake_case

This commit is contained in:
Martin Thoma
2022-04-02 11:21:11 +02:00
parent ac184fec42
commit e17388d072
13 changed files with 167 additions and 178 deletions

View File

@@ -7,16 +7,15 @@ From: BASIC Computer Games (1978)
Python port by Aviyam Fischer, 2022
"""
from typing import List, Literal, TypeAlias, get_args
from typing import List, Literal, NamedTuple, TypeAlias, get_args
Suit: TypeAlias = Literal["\u2665", "\u2666", "\u2663", "\u2660"]
Rank: TypeAlias = Literal[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
class Card:
def __init__(self, suit: Suit, rank: Rank) -> None:
self.suit = suit
self.rank = rank
class Card(NamedTuple):
suit: Suit
rank: Rank
def __str__(self) -> str:
r = str(self.rank)