Skip to content

Commit

Permalink
feat[yagom-academy#1]: Step1 - 요구사항 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
iluxsm committed Nov 22, 2020
1 parent a02ced5 commit e73c4e0
Showing 1 changed file with 58 additions and 2 deletions.
60 changes: 58 additions & 2 deletions JuiceMaker/JuiceMaker/JuiceMaker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,62 @@
// Copyright © yagom academy. All rights reserved.
//

import Foundation
import UIKit

/// 쥬스 메이커 타입
enum FruitsName {
case strawberry, banana, pineapple, kiwi, mango
}

struct FruitsLabel {
let fruitsArray: [String] = ["strawberry", "banana", "pineapple", "kiwi", "mango"]
}

class FruitStock: NSObject {
@objc fileprivate(set) var strawberry: Int = 10
@objc fileprivate(set) var banana: Int = 10
@objc fileprivate(set) var pineapple: Int = 10
@objc fileprivate(set) var kiwi: Int = 10
@objc fileprivate(set) var mango: Int = 10

func addStocks(fruitsName: FruitsName, amount: Int) {
for fruit in FruitsLabel().fruitsArray {
if fruit == "\(fruitsName)" {
if let addFruit = value(forKey: fruit) as? Int {
setValue(addFruit + amount, forKey: fruit)
} else {
print("존재하지 않는 과일입니다. 알림 구현")
}
}
}
}
}

class JuiceMaker: FruitStock {
func makeOriginalJuice(material fruit: FruitsName) {
switch fruit {
case .strawberry:
strawberry -= 16
case .banana:
banana -= 2
case .pineapple:
pineapple -= 2
case .kiwi:
kiwi -= 3
case .mango:
mango -= 3
}
}

func makeMixedJuice(fruit1: FruitsName, fruit2: FruitsName) {
switch (fruit1, fruit2) {
case (.strawberry, .banana), (.banana, .strawberry):
strawberry -= 10
banana -= 1
case (.kiwi, .mango), (.mango, .kiwi):
kiwi -= 2
mango -= 1
default:
print("메뉴 준비 중이라는 알림 구현")
}
}
}

0 comments on commit e73c4e0

Please sign in to comment.