-
Notifications
You must be signed in to change notification settings - Fork 0
/
NumeroUnoSoftwareStore.swift
72 lines (59 loc) · 1.86 KB
/
NumeroUnoSoftwareStore.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
71
72
//product types
enum ProductType: String, CaseIterable {
case aceRepository = "Ace Repository"
case dealForcer = "Deal Forcer"
case kadencePlanner = "Kadence Planner"
case mailCannon = "Mail Cannon"
}
func displayProductOffering(){
print("There are \(ProductType.allCases.count) products:")
for product in ProductType.allCases {
print(product.rawValue)
}
}
//order confirmation method
func sendOrderConfirmation(of productType: ProductType, and edition: Edition, using deliveryMethod: DeliveryMethod) {
print("Thank you for purchasing the \(edition.rawValue) edition of \(productType.rawValue)")
switch deliveryMethod{
case .shipping:
print("Your order will be shipped to you at a cost of $\(deliveryMethod.shippingCost)")
case .cloudDigital(let isLifetime):
if isLifetime {
print("You have lifetime cloud access")
} else {
print("You can access your subscription information in the cloud")
}
}
}
//upgrades
enum Edition:String,CaseIterable {
case basic
case premium
case ultimate
mutating func upgrade() {
switch self {
case .basic:
self = .premium
case .premium:
self = .ultimate
case .ultimate:
print("Can't upgrade further")
}
}
}
//Delivery method
enum DeliveryMethod {
case shipping(weight: Int)
case cloudDigital(isLifetime: Bool)
var shippingCost : Int {
switch self {
case .shipping(let weight):
return weight * 2
case .cloudDigital:
return 0
}
}
}
var myEdition = Edition.basic
myEdition.upgrade()
sendOrderConfirmation(of: ProductType.aceRepository, and: myEdition, using: DeliveryMethod.shipping(weight: 1))