From b659af9184ac2ae26003fbd67ed25d02fa3a4a02 Mon Sep 17 00:00:00 2001 From: Stian Lyng <stianlyng@protonmail.com> Date: Thu, 4 May 2023 16:41:06 +0200 Subject: [PATCH] limit items to 5 --- .../idatt2016/v233/SmartMat/service/RecipeService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/RecipeService.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/RecipeService.java index d99ca41f..0afaa635 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/RecipeService.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/RecipeService.java @@ -229,7 +229,13 @@ public class RecipeService { Collections.shuffle(zeroMatchRecipes); // Combine the commonRecipes and zeroMatchRecipes lists - commonRecipes.addAll(zeroMatchRecipes); + for (RecipeWithMatchCount zeroMatchRecipe : zeroMatchRecipes) { + if (commonRecipes.size() < 5) { + commonRecipes.add(zeroMatchRecipe); + } else { + break; + } + } return commonRecipes; } } \ No newline at end of file -- GitLab