Skip to content

Commit

Permalink
refactor: FruitsInventory 타입 분리 #1
Browse files Browse the repository at this point in the history
  • Loading branch information
김정상 committed Feb 17, 2022
1 parent 54306b3 commit 0a0b0a4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
4 changes: 0 additions & 4 deletions JuiceMaker/JuiceMaker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
73B6685227BBE7CE005CF6E3 /* FruitType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73B6685127BBE7CE005CF6E3 /* FruitType.swift */; };
73B6686127BC026A005CF6E3 /* FruitStoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73B6685927BBFEE3005CF6E3 /* FruitStoreTests.swift */; };
73B6686327BD18D3005CF6E3 /* JuiceRecipes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73B6686227BD18D3005CF6E3 /* JuiceRecipes.swift */; };
73B6686727BD37CE005CF6E3 /* FruitsInventory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73B6686627BD37CE005CF6E3 /* FruitsInventory.swift */; };
C71CD66B266C7ACB0038B9CB /* FruitStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = C71CD66A266C7ACB0038B9CB /* FruitStore.swift */; };
C73DAF37255D0CDD00020D38 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C73DAF36255D0CDD00020D38 /* AppDelegate.swift */; };
C73DAF39255D0CDD00020D38 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C73DAF38255D0CDD00020D38 /* SceneDelegate.swift */; };
Expand All @@ -38,7 +37,6 @@
73B6685727BBFEE3005CF6E3 /* JuiceMakerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JuiceMakerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
73B6685927BBFEE3005CF6E3 /* FruitStoreTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FruitStoreTests.swift; sourceTree = "<group>"; };
73B6686227BD18D3005CF6E3 /* JuiceRecipes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JuiceRecipes.swift; sourceTree = "<group>"; };
73B6686627BD37CE005CF6E3 /* FruitsInventory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FruitsInventory.swift; sourceTree = "<group>"; };
C71CD66A266C7ACB0038B9CB /* FruitStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FruitStore.swift; sourceTree = "<group>"; };
C73DAF33255D0CDD00020D38 /* JuiceMaker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JuiceMaker.app; sourceTree = BUILT_PRODUCTS_DIR; };
C73DAF36255D0CDD00020D38 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -91,7 +89,6 @@
C71CD66F266C7B500038B9CB /* Model */ = {
isa = PBXGroup;
children = (
73B6686627BD37CE005CF6E3 /* FruitsInventory.swift */,
C71CD66A266C7ACB0038B9CB /* FruitStore.swift */,
73B6685127BBE7CE005CF6E3 /* FruitType.swift */,
C73DAF4B255D0D0400020D38 /* JuiceMaker.swift */,
Expand Down Expand Up @@ -251,7 +248,6 @@
C71CD66B266C7ACB0038B9CB /* FruitStore.swift in Sources */,
73B6686327BD18D3005CF6E3 /* JuiceRecipes.swift in Sources */,
C73DAF3B255D0CDD00020D38 /* ViewController.swift in Sources */,
73B6686727BD37CE005CF6E3 /* FruitsInventory.swift in Sources */,
C73DAF37255D0CDD00020D38 /* AppDelegate.swift in Sources */,
C73DAF39255D0CDD00020D38 /* SceneDelegate.swift in Sources */,
73B6685227BBE7CE005CF6E3 /* FruitType.swift in Sources */,
Expand Down
3 changes: 3 additions & 0 deletions JuiceMaker/JuiceMaker/Model/FruitStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ extension FruitStoreError: LocalizedError {

/// 과일 저장소 타입
final class FruitStore {

typealias FruitsInventory = [FruitType: Int]

private(set) var inventory = FruitsInventory()

init(initialFruitCount: Int = 10) {
Expand Down
10 changes: 0 additions & 10 deletions JuiceMaker/JuiceMaker/Model/FruitsInventory.swift

This file was deleted.

18 changes: 10 additions & 8 deletions JuiceMaker/JuiceMaker/Model/JuiceRecipes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,51 @@

import Foundation

typealias FruitItems = [FruitType: Int]

protocol RecipeProtocol {
var items: FruitsInventory { get }
var items: FruitItems { get }
}

struct StrawberryJuice: RecipeProtocol {
var items: FruitsInventory = [
var items: FruitItems = [
.strawberry: 16
]
}

struct BananaJuice: RecipeProtocol {
var items: FruitsInventory = [
var items: FruitItems = [
.banana: 2
]
}

struct PineappleJuice: RecipeProtocol {
var items: FruitsInventory = [
var items: FruitItems = [
.pineapple: 2
]
}

struct KiwiJuice: RecipeProtocol {
var items: FruitsInventory = [
var items: FruitItems = [
.kiwi: 3
]
}

struct MangoJuice: RecipeProtocol {
var items: FruitsInventory = [
var items: FruitItems = [
.mango: 3
]
}

struct StrawberryBananaJuice: RecipeProtocol {
var items: FruitsInventory = [
var items: FruitItems = [
.strawberry: 10,
.banana: 1
]
}

struct MangoKiwiJuice: RecipeProtocol {
var items: FruitsInventory = [
var items: FruitItems = [
.mango: 2,
.kiwi: 1
]
Expand Down

0 comments on commit 0a0b0a4

Please sign in to comment.