-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from GREENOVER/step1
Step1 쥬스 메이커 타입 정의
- Loading branch information
Showing
3 changed files
with
82 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,83 @@ | ||
// | ||
// JuiceMaker - JuiceMaker.swift | ||
// Created by yagom. | ||
// Copyright © yagom academy. All rights reserved. | ||
// | ||
//그린 | ||
|
||
// 쥬스 메이커 타입 | ||
|
||
import Foundation | ||
|
||
/// 쥬스 메이커 타입 | ||
enum Juice { | ||
case strawberryJuice | ||
case bananaJuice | ||
case pineappleJuice | ||
case kiwiJuice | ||
case mangoJuice | ||
case strawberryBananaJuice | ||
case mangoKiwiJuice | ||
} | ||
|
||
enum Fruit { | ||
case strawberry | ||
case banana | ||
case pineapple | ||
case kiwi | ||
case mango | ||
} | ||
|
||
class JuiceMaker { | ||
var strawberryStock: Int = 10 | ||
var bananaStock: Int = 10 | ||
var pineappleStock: Int = 10 | ||
var kiwiStock: Int = 10 | ||
var mangoStock: Int = 10 | ||
|
||
func makeJuice(_ juice: Juice) { | ||
switch juice { | ||
case .strawberryJuice: | ||
strawberryStock -= 3 | ||
case .bananaJuice: | ||
bananaStock -= 3 | ||
case .pineappleJuice: | ||
pineappleStock -= 3 | ||
case .kiwiJuice: | ||
kiwiStock -= 3 | ||
case .mangoJuice: | ||
mangoStock -= 3 | ||
case .strawberryBananaJuice: | ||
strawberryStock -= 10 | ||
bananaStock -= 1 | ||
case .mangoKiwiJuice: | ||
mangoStock -= 2 | ||
kiwiStock -= 1 | ||
} | ||
} | ||
|
||
func addFruitStock(_ fruit: Fruit) { | ||
switch fruit { | ||
case .strawberry: | ||
strawberryStock += 1 | ||
case .banana: | ||
bananaStock += 1 | ||
case .pineapple: | ||
pineappleStock += 1 | ||
case .kiwi: | ||
kiwiStock += 1 | ||
case .mango: | ||
mangoStock += 1 | ||
} | ||
} | ||
|
||
func removeFruitStock(_ fruit: Fruit) { | ||
switch fruit { | ||
case .strawberry: | ||
strawberryStock -= 1 | ||
case .banana: | ||
bananaStock -= 1 | ||
case .pineapple: | ||
pineappleStock -= 1 | ||
case .kiwi: | ||
kiwiStock -= 1 | ||
case .mango: | ||
mangoStock -= 1 | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,12 @@ | ||
// | ||
// JuiceMaker - ViewController.swift | ||
// Created by yagom. | ||
// Copyright © yagom academy. All rights reserved. | ||
// | ||
//GREEN | ||
|
||
import UIKit | ||
|
||
class ViewController: UIViewController { | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
// Do any additional setup after loading the view. | ||
} | ||
|
||
|
||
|
||
} | ||
|