diff --git a/prototype/src/main/java/org/hso/ecommerce/action/shop/GetRandomArticlesAction.java b/prototype/src/main/java/org/hso/ecommerce/action/shop/GetRandomArticlesAction.java index c299b92..62c70c7 100644 --- a/prototype/src/main/java/org/hso/ecommerce/action/shop/GetRandomArticlesAction.java +++ b/prototype/src/main/java/org/hso/ecommerce/action/shop/GetRandomArticlesAction.java @@ -9,7 +9,7 @@ public class GetRandomArticlesAction { public static List
getRandomArticles(int quantity, List
advertisedArticles) { List
randomisedArticles = new ArrayList
(); - int loopcount = quantity > advertisedArticles.size() ? advertisedArticles.size() : quantity; + int loopcount = Math.min(quantity, advertisedArticles.size()); for (int i = 0; i < loopcount; i++) { int index = (int) (Math.random() * advertisedArticles.size()); randomisedArticles.add(advertisedArticles.remove(index));