-
Notifications
You must be signed in to change notification settings - Fork 0
/
City.swift
70 lines (59 loc) · 1.67 KB
/
City.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// City.swift
// Wanderlust
//
// Created by Mihikaa Goenka on 8/6/19.
// Copyright © 2019 Mihikaa Goenka. All rights reserved.
//
import Foundation
import UIKit
protocol Filter {
var filterTitle: String { get }
}
enum ContinentName: Filter {
case asia
case europe
case northamerica
case southamerica
case australia
case africa
var filterTitle: String { //return the enum title with first letter uppercased
if String(describing: self) == "northamerica" {
return "NORTH AMERICA"
}
else if String(describing: self) == "southamerica"{
return "SOUTH AMERICA"
}
else{
return String(describing: self).localizedUppercase
}
}
static func allValues() -> [ContinentName] {
return
[.asia, .europe, .northamerica, .southamerica, .australia, .africa]
}
}
enum LocationType: Filter {
case beach
case mountain
case city
case grassland
var filterTitle: String { //return the enum title with first letter uppercased
return String(describing: self).localizedUppercase
}
static func allValues() -> [LocationType] {
return [.beach, .mountain, .city, .grassland]
}
}
class City {
var name: String
var cityimagestring: String
let continent: ContinentName //can only belong to one continent
let landscape: [LocationType]
init(name: String, cityimagestring: String, continent: ContinentName, landscape: [LocationType]){
self.name = name
self.cityimagestring = cityimagestring
self.continent = continent
self.landscape = landscape
}
}