-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGermanName.swift
53 lines (45 loc) · 1.12 KB
/
GermanName.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// GermanName.swift
// Namer
//
// Created by Shahin on 26.01.25.
//
import Foundation
struct GermanName: Identifiable, Codable, Hashable {
let id = UUID()
let firstName: String
let lastName: String
let gender: Gender
let birthYear: Int
enum Gender: String, Codable, CaseIterable {
case male = "Männlich"
case female = "Weiblich"
}
}
struct NameCollection: Identifiable, Codable {
let id = UUID()
var name: String
var names: [GermanName]
}
enum AgeGroup: CaseIterable {
case child
case teenager
case youngAdult
case adult
case middleAge
case senior
case elderly
static func getAgeGroup(birthYear: Int) -> AgeGroup {
let currentYear = Calendar.current.component(.year, from: Date())
let age = currentYear - birthYear
switch age {
case 0...12: return .child
case 13...19: return .teenager
case 20...30: return .youngAdult
case 31...45: return .adult
case 46...60: return .middleAge
case 61...75: return .senior
default: return .elderly
}
}
}