Skip to content

Commit

Permalink
Merge pull request #81 from jetbrains-academy/fix-cooking-soup
Browse files Browse the repository at this point in the history
Fix cooking soup
  • Loading branch information
nbirillo authored Oct 16, 2024
2 parents 9472c2b + 7312fbb commit 0efb5f2
Show file tree
Hide file tree
Showing 20 changed files with 60 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.jetbrains.kotlin.course.culinary.game
import org.jetbrains.kotlin.course.culinary.converters.toItemType
import org.jetbrains.kotlin.course.culinary.game.recipes.NUMBER_OF_TOMATOES
import org.jetbrains.kotlin.course.culinary.game.recipes.NUM_VEGETABLES_FOR_SALAD
import org.jetbrains.kotlin.course.culinary.implementation.cooking.PotImpl
import org.jetbrains.kotlin.course.culinary.implementation.storage.FridgeImpl
import org.jetbrains.kotlin.course.culinary.models.ItemType
import org.jetbrains.kotlin.course.culinary.models.Task
Expand All @@ -24,22 +25,24 @@ class CookingFunction(val service: CookingService) {
@GetMapping("/tomato-soup")
fun tomatoSoup(): List<Action> {
clearActions()
PotImpl.reset()
if (FridgeImpl.vegetables.count{ it.type == VegetableType.Tomato && it.isFresh } < NUMBER_OF_TOMATOES) {
// Show an error
return emptyList()
}

service.cookTomatoSoup()
clearKitchen()
PotImpl.simmering = false
return actions
}

@CrossOrigin
@GetMapping("/soup-spices")
fun soupSpices(): List<Action> {
clearActions()
PotImpl.reset()
service.cookWithSpices()
clearKitchen()
PotImpl.simmering = false
return actions
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data object PotImpl : Pot {
override fun doesTastePerfect(): Boolean = filling.filter{ it is Spice }
.groupingBy{ it }
.eachCount()
.filter{ (_, n) -> n > 2 }
.filter{ (_, n) -> n >= 2 }
.isEmpty()

override fun <T: Ingredient> put(ingredient: T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.jetbrains.kotlin.course.culinary.game
import org.jetbrains.kotlin.course.culinary.converters.toItemType
import org.jetbrains.kotlin.course.culinary.game.recipes.NUMBER_OF_TOMATOES
import org.jetbrains.kotlin.course.culinary.game.recipes.NUM_VEGETABLES_FOR_SALAD
import org.jetbrains.kotlin.course.culinary.implementation.cooking.PotImpl
import org.jetbrains.kotlin.course.culinary.implementation.storage.FridgeImpl
import org.jetbrains.kotlin.course.culinary.models.ItemType
import org.jetbrains.kotlin.course.culinary.models.Task
Expand All @@ -24,22 +25,24 @@ class CookingFunction(val service: CookingService) {
@GetMapping("/tomato-soup")
fun tomatoSoup(): List<Action> {
clearActions()
PotImpl.reset()
if (FridgeImpl.vegetables.count{ it.type == VegetableType.Tomato && it.isFresh } < NUMBER_OF_TOMATOES) {
// Show an error
return emptyList()
}

service.cookTomatoSoup()
clearKitchen()
PotImpl.simmering = false
return actions
}

@CrossOrigin
@GetMapping("/soup-spices")
fun soupSpices(): List<Action> {
clearActions()
PotImpl.reset()
service.cookWithSpices()
clearKitchen()
PotImpl.simmering = false
return actions
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data object PotImpl : Pot {
override fun doesTastePerfect(): Boolean = filling.filter{ it is Spice }
.groupingBy{ it }
.eachCount()
.filter{ (_, n) -> n > 2 }
.filter{ (_, n) -> n >= 2 }
.isEmpty()

override fun <T: Ingredient> put(ingredient: T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.jetbrains.kotlin.course.culinary.game
import org.jetbrains.kotlin.course.culinary.converters.toItemType
import org.jetbrains.kotlin.course.culinary.game.recipes.NUMBER_OF_TOMATOES
import org.jetbrains.kotlin.course.culinary.game.recipes.NUM_VEGETABLES_FOR_SALAD
import org.jetbrains.kotlin.course.culinary.implementation.cooking.PotImpl
import org.jetbrains.kotlin.course.culinary.implementation.storage.FridgeImpl
import org.jetbrains.kotlin.course.culinary.models.ItemType
import org.jetbrains.kotlin.course.culinary.models.Task
Expand All @@ -24,22 +25,24 @@ class CookingFunction(val service: CookingService) {
@GetMapping("/tomato-soup")
fun tomatoSoup(): List<Action> {
clearActions()
PotImpl.reset()
if (FridgeImpl.vegetables.count{ it.type == VegetableType.Tomato && it.isFresh } < NUMBER_OF_TOMATOES) {
// Show an error
return emptyList()
}

service.cookTomatoSoup()
clearKitchen()
PotImpl.simmering = false
return actions
}

@CrossOrigin
@GetMapping("/soup-spices")
fun soupSpices(): List<Action> {
clearActions()
PotImpl.reset()
service.cookWithSpices()
clearKitchen()
PotImpl.simmering = false
return actions
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data object PotImpl : Pot {
override fun doesTastePerfect(): Boolean = filling.filter{ it is Spice }
.groupingBy{ it }
.eachCount()
.filter{ (_, n) -> n > 2 }
.filter{ (_, n) -> n >= 2 }
.isEmpty()

override fun <T: Ingredient> put(ingredient: T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.jetbrains.kotlin.course.culinary.game
import org.jetbrains.kotlin.course.culinary.converters.toItemType
import org.jetbrains.kotlin.course.culinary.game.recipes.NUMBER_OF_TOMATOES
import org.jetbrains.kotlin.course.culinary.game.recipes.NUM_VEGETABLES_FOR_SALAD
import org.jetbrains.kotlin.course.culinary.implementation.cooking.PotImpl
import org.jetbrains.kotlin.course.culinary.implementation.storage.FridgeImpl
import org.jetbrains.kotlin.course.culinary.models.ItemType
import org.jetbrains.kotlin.course.culinary.models.Task
Expand All @@ -24,22 +25,24 @@ class CookingFunction(val service: CookingService) {
@GetMapping("/tomato-soup")
fun tomatoSoup(): List<Action> {
clearActions()
PotImpl.reset()
if (FridgeImpl.vegetables.count{ it.type == VegetableType.Tomato && it.isFresh } < NUMBER_OF_TOMATOES) {
// Show an error
return emptyList()
}

service.cookTomatoSoup()
clearKitchen()
PotImpl.simmering = false
return actions
}

@CrossOrigin
@GetMapping("/soup-spices")
fun soupSpices(): List<Action> {
clearActions()
PotImpl.reset()
service.cookWithSpices()
clearKitchen()
PotImpl.simmering = false
return actions
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data object PotImpl : Pot {
override fun doesTastePerfect(): Boolean = filling.filter{ it is Spice }
.groupingBy{ it }
.eachCount()
.filter{ (_, n) -> n > 2 }
.filter{ (_, n) -> n >= 2 }
.isEmpty()

override fun <T: Ingredient> put(ingredient: T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.jetbrains.kotlin.course.culinary.game
import org.jetbrains.kotlin.course.culinary.converters.toItemType
import org.jetbrains.kotlin.course.culinary.game.recipes.NUMBER_OF_TOMATOES
import org.jetbrains.kotlin.course.culinary.game.recipes.NUM_VEGETABLES_FOR_SALAD
import org.jetbrains.kotlin.course.culinary.implementation.cooking.PotImpl
import org.jetbrains.kotlin.course.culinary.implementation.storage.FridgeImpl
import org.jetbrains.kotlin.course.culinary.models.ItemType
import org.jetbrains.kotlin.course.culinary.models.Task
Expand All @@ -24,22 +25,24 @@ class CookingFunction(val service: CookingService) {
@GetMapping("/tomato-soup")
fun tomatoSoup(): List<Action> {
clearActions()
PotImpl.reset()
if (FridgeImpl.vegetables.count{ it.type == VegetableType.Tomato && it.isFresh } < NUMBER_OF_TOMATOES) {
// Show an error
return emptyList()
}

service.cookTomatoSoup()
clearKitchen()
PotImpl.simmering = false
return actions
}

@CrossOrigin
@GetMapping("/soup-spices")
fun soupSpices(): List<Action> {
clearActions()
PotImpl.reset()
service.cookWithSpices()
clearKitchen()
PotImpl.simmering = false
return actions
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data object PotImpl : Pot {
override fun doesTastePerfect(): Boolean = filling.filter{ it is Spice }
.groupingBy{ it }
.eachCount()
.filter{ (_, n) -> n > 2 }
.filter{ (_, n) -> n >= 2 }
.isEmpty()

override fun <T: Ingredient> put(ingredient: T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.jetbrains.kotlin.course.culinary.game
import org.jetbrains.kotlin.course.culinary.converters.toItemType
import org.jetbrains.kotlin.course.culinary.game.recipes.NUMBER_OF_TOMATOES
import org.jetbrains.kotlin.course.culinary.game.recipes.NUM_VEGETABLES_FOR_SALAD
import org.jetbrains.kotlin.course.culinary.implementation.cooking.PotImpl
import org.jetbrains.kotlin.course.culinary.implementation.storage.FridgeImpl
import org.jetbrains.kotlin.course.culinary.models.ItemType
import org.jetbrains.kotlin.course.culinary.models.Task
Expand All @@ -24,22 +25,24 @@ class CookingFunction(val service: CookingService) {
@GetMapping("/tomato-soup")
fun tomatoSoup(): List<Action> {
clearActions()
PotImpl.reset()
if (FridgeImpl.vegetables.count{ it.type == VegetableType.Tomato && it.isFresh } < NUMBER_OF_TOMATOES) {
// Show an error
return emptyList()
}

service.cookTomatoSoup()
clearKitchen()
PotImpl.simmering = false
return actions
}

@CrossOrigin
@GetMapping("/soup-spices")
fun soupSpices(): List<Action> {
clearActions()
PotImpl.reset()
service.cookWithSpices()
clearKitchen()
PotImpl.simmering = false
return actions
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data object PotImpl : Pot {
override fun doesTastePerfect(): Boolean = filling.filter{ it is Spice }
.groupingBy{ it }
.eachCount()
.filter{ (_, n) -> n > 2 }
.filter{ (_, n) -> n >= 2 }
.isEmpty()

override fun <T: Ingredient> put(ingredient: T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.jetbrains.kotlin.course.culinary.game
import org.jetbrains.kotlin.course.culinary.converters.toItemType
import org.jetbrains.kotlin.course.culinary.game.recipes.NUMBER_OF_TOMATOES
import org.jetbrains.kotlin.course.culinary.game.recipes.NUM_VEGETABLES_FOR_SALAD
import org.jetbrains.kotlin.course.culinary.implementation.cooking.PotImpl
import org.jetbrains.kotlin.course.culinary.implementation.storage.FridgeImpl
import org.jetbrains.kotlin.course.culinary.models.ItemType
import org.jetbrains.kotlin.course.culinary.models.Task
Expand All @@ -24,22 +25,24 @@ class CookingFunction(val service: CookingService) {
@GetMapping("/tomato-soup")
fun tomatoSoup(): List<Action> {
clearActions()
PotImpl.reset()
if (FridgeImpl.vegetables.count{ it.type == VegetableType.Tomato && it.isFresh } < NUMBER_OF_TOMATOES) {
// Show an error
return emptyList()
}

service.cookTomatoSoup()
clearKitchen()
PotImpl.simmering = false
return actions
}

@CrossOrigin
@GetMapping("/soup-spices")
fun soupSpices(): List<Action> {
clearActions()
PotImpl.reset()
service.cookWithSpices()
clearKitchen()
PotImpl.simmering = false
return actions
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data object PotImpl : Pot {
override fun doesTastePerfect(): Boolean = filling.filter{ it is Spice }
.groupingBy{ it }
.eachCount()
.filter{ (_, n) -> n > 2 }
.filter{ (_, n) -> n >= 2 }
.isEmpty()

override fun <T: Ingredient> put(ingredient: T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.jetbrains.kotlin.course.culinary.game
import org.jetbrains.kotlin.course.culinary.converters.toItemType
import org.jetbrains.kotlin.course.culinary.game.recipes.NUMBER_OF_TOMATOES
import org.jetbrains.kotlin.course.culinary.game.recipes.NUM_VEGETABLES_FOR_SALAD
import org.jetbrains.kotlin.course.culinary.implementation.cooking.PotImpl
import org.jetbrains.kotlin.course.culinary.implementation.storage.FridgeImpl
import org.jetbrains.kotlin.course.culinary.models.ItemType
import org.jetbrains.kotlin.course.culinary.models.Task
Expand All @@ -24,22 +25,24 @@ class CookingFunction(val service: CookingService) {
@GetMapping("/tomato-soup")
fun tomatoSoup(): List<Action> {
clearActions()
PotImpl.reset()
if (FridgeImpl.vegetables.count{ it.type == VegetableType.Tomato && it.isFresh } < NUMBER_OF_TOMATOES) {
// Show an error
return emptyList()
}

service.cookTomatoSoup()
clearKitchen()
PotImpl.simmering = false
return actions
}

@CrossOrigin
@GetMapping("/soup-spices")
fun soupSpices(): List<Action> {
clearActions()
PotImpl.reset()
service.cookWithSpices()
clearKitchen()
PotImpl.simmering = false
return actions
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data object PotImpl : Pot {
override fun doesTastePerfect(): Boolean = filling.filter{ it is Spice }
.groupingBy{ it }
.eachCount()
.filter{ (_, n) -> n > 2 }
.filter{ (_, n) -> n >= 2 }
.isEmpty()

override fun <T: Ingredient> put(ingredient: T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.jetbrains.kotlin.course.culinary.game
import org.jetbrains.kotlin.course.culinary.converters.toItemType
import org.jetbrains.kotlin.course.culinary.game.recipes.NUMBER_OF_TOMATOES
import org.jetbrains.kotlin.course.culinary.game.recipes.NUM_VEGETABLES_FOR_SALAD
import org.jetbrains.kotlin.course.culinary.implementation.cooking.PotImpl
import org.jetbrains.kotlin.course.culinary.implementation.storage.FridgeImpl
import org.jetbrains.kotlin.course.culinary.models.ItemType
import org.jetbrains.kotlin.course.culinary.models.Task
Expand All @@ -24,22 +25,24 @@ class CookingFunction(val service: CookingService) {
@GetMapping("/tomato-soup")
fun tomatoSoup(): List<Action> {
clearActions()
PotImpl.reset()
if (FridgeImpl.vegetables.count{ it.type == VegetableType.Tomato && it.isFresh } < NUMBER_OF_TOMATOES) {
// Show an error
return emptyList()
}

service.cookTomatoSoup()
clearKitchen()
PotImpl.simmering = false
return actions
}

@CrossOrigin
@GetMapping("/soup-spices")
fun soupSpices(): List<Action> {
clearActions()
PotImpl.reset()
service.cookWithSpices()
clearKitchen()
PotImpl.simmering = false
return actions
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data object PotImpl : Pot {
override fun doesTastePerfect(): Boolean = filling.filter{ it is Spice }
.groupingBy{ it }
.eachCount()
.filter{ (_, n) -> n > 2 }
.filter{ (_, n) -> n >= 2 }
.isEmpty()

override fun <T: Ingredient> put(ingredient: T) {
Expand Down
Loading

0 comments on commit 0efb5f2

Please sign in to comment.