From 23447a96d698d2119f46b36863f8251818fd6726 Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Mon, 19 Jan 2026 14:38:21 +0100 Subject: [PATCH] feat(commons/recipe): introduce weight sum calculations --- commons/src/main/java/commons/Recipe.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/commons/src/main/java/commons/Recipe.java b/commons/src/main/java/commons/Recipe.java index f69ca35..e60fd30 100644 --- a/commons/src/main/java/commons/Recipe.java +++ b/commons/src/main/java/commons/Recipe.java @@ -203,7 +203,10 @@ public class Recipe { final double PER = 100; // Gram return this.ingredients.stream().mapToDouble(RecipeIngredient::getKcal).sum() / - this.ingredients.stream().mapToDouble(RecipeIngredient::getBaseAmount).sum() * PER; + weight() * PER; + } + public double weight() { + return this.ingredients.stream().mapToDouble(RecipeIngredient::getBaseAmount).sum(); } }