32 lines
692 B
Swift
32 lines
692 B
Swift
//
|
|
// MemoryGame.swift
|
|
// Memorize
|
|
//
|
|
// Created by ching on 2023/2/12.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
// model
|
|
struct MemoryGame<CardContent> {
|
|
private(set) var cards: [Card]
|
|
|
|
func choose(_ card: Card) {}
|
|
|
|
init(numberOfPairsOfCards: Int, createCardContent: (Int) -> CardContent) {
|
|
cards = [Card]()
|
|
//
|
|
for pairIndex in 0 ..< numberOfPairsOfCards {
|
|
let content: CardContent = createCardContent(pairIndex)
|
|
cards.append(Card(content: content))
|
|
cards.append(Card(content: content))
|
|
}
|
|
}
|
|
|
|
struct Card {
|
|
var isFaceUp: Bool = false
|
|
var isMatched: Bool = false
|
|
var content: CardContent
|
|
}
|
|
}
|