Add table persistence, organize files

This commit is contained in:
Christoph Hagen
2021-12-01 22:47:19 +01:00
parent 7265fd0f0d
commit cde63c03d6
9 changed files with 410 additions and 214 deletions

View File

@ -1,58 +0,0 @@
import Foundation
typealias CardId = String
struct Card {
enum Symbol: Character {
case ass = "A"
case zehn = "Z"
case könig = "K"
case ober = "O"
case unter = "U"
case neun = "9"
case acht = "8"
case sieben = "7"
}
enum Suit: Character {
case eichel = "E"
case blatt = "B"
case herz = "H"
case schelln = "S"
}
let symbol: Symbol
let suit: Suit
init(suit: Suit, symbol: Symbol) {
self.suit = suit
self.symbol = symbol
}
init?(rawValue: String) {
guard rawValue.count == 2 else {
return nil
}
guard let suit = Suit(rawValue: rawValue.first!),
let symbol = Symbol(rawValue: rawValue.last!) else {
return nil
}
self.suit = suit
self.symbol = symbol
}
var id: CardId {
"\(suit)\(symbol)"
}
}
extension Card: CustomStringConvertible {
var description: String {
id
}
}