Skip to content

Commit

Permalink
Merge pull request #1 from stevenkim18/steven-test
Browse files Browse the repository at this point in the history
steven-test 브런치에서 머지
  • Loading branch information
stevenkim18 committed Mar 9, 2021
2 parents a02ced5 + 48267db commit 3f02ddf
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 8 deletions.
18 changes: 13 additions & 5 deletions JuiceMaker/JuiceMaker/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="landscape" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="JuiceMaker" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="667" height="375"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-306" y="191"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
52 changes: 51 additions & 1 deletion JuiceMaker/JuiceMaker/JuiceMaker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,54 @@

import Foundation

/// 쥬스 메이커 타입
enum Fruit: Int, CaseIterable {
case strawberry, banana, pineapple, kiwi, mango

var index: Int {
return self.rawValue
}
}

enum FruitJuice {
case strawberry, banana, kiwi, pineapple, strawberryBanana, mango, mangoKiwi
}

class JuiceMaker {
private var fruitStocks = [Int](repeating: 10, count: Fruit.allCases.count)

func checkStock(fruit: Fruit) -> Int {
return fruitStocks[fruit.index]
}
func checkStockAvailable(fruit: Fruit, stock: Int) -> Bool {
if (checkStock(fruit: fruit) < stock) {
return false
}
return true
}
func consumeFruit(fruit: Fruit, stock: Int) {
fruitStocks[fruit.index] -= stock
}
func makeFruitJuice(juice: FruitJuice) {
switch juice {
case .strawberry:
consumeFruit(fruit: .strawberry, stock: 16)
case .banana:
consumeFruit(fruit: .banana, stock: 2)
case .kiwi:
consumeFruit(fruit: .kiwi, stock: 3)
case .pineapple:
consumeFruit(fruit: .pineapple, stock: 2)
case .strawberryBanana:
consumeFruit(fruit: .strawberry, stock: 10)
consumeFruit(fruit: .banana, stock: 1)
case .mango:
consumeFruit(fruit: .mango, stock: 3)
case .mangoKiwi:
consumeFruit(fruit: .mango, stock: 2)
consumeFruit(fruit: .kiwi, stock: 1)
}
}
func addStock(fruit: Fruit) {
fruitStocks[fruit.index] += 1
}
}
9 changes: 7 additions & 2 deletions JuiceMaker/JuiceMaker/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.

let j = JuiceMaker()
print(j.checkStock(fruit: .strawberry))
j.addStock(fruit: .strawberry)
print(j.checkStock(fruit: .strawberry))


}


}

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# steven-test

0 comments on commit 3f02ddf

Please sign in to comment.