krz/daybyday

iOS learning games for young children: days, months, seasons, numbers, letters, animals and more. education ios kids swift https://krz.sh/apps/daybyday/

DayByDay/Quiz/PraisePhrases.swift

062549ad26607ce9e973ed2a9a7ef6f853885f83
daybyday/DayByDay/Quiz/PraisePhrases.swift history · blame · raw

32 lines · 738 bytes

2 symbols in this file
 1//
 2//  PraisePhrases.swift
 3//  DayByDay
 4//
 5
 6nonisolated struct PraisePhrases {
 7    static let all = [
 8        "Great job!",
 9        "You got it!",
10        "Super!",
11        "Way to go!",
12        "Awesome!",
13        "Yes, that's right!",
14        "Nice work!",
15        "You did great!",
16        "Hooray!",
17        "Fantastic!",
18    ]
19
20    private var last: String?
21
22    /// A random phrase, never the same as the previous one.
23    mutating func next(using rng: inout some RandomNumberGenerator) -> String {
24        let phrase = Self.all.filter { $0 != last }.randomElement(using: &rng)!
25        last = phrase
26        return phrase
27    }
28
29    static func correction(for name: String) -> String {
30        "That's \(name)! Try again."
31    }
32}