Implement monolith shop discounts

This commit is contained in:
Melledy
2025-12-03 23:15:25 -08:00
parent 71de6184b9
commit 15618414a6
4 changed files with 91 additions and 3 deletions

View File

@@ -179,12 +179,34 @@ public class Utils {
}
public static <T> T randomElement(List<T> list) {
return list.get(ThreadLocalRandom.current().nextInt(0, list.size()));
return randomElement(list, false);
}
public static <T> T randomElement(List<T> list, boolean remove) {
int index = ThreadLocalRandom.current().nextInt(0, list.size());
var object = list.get(index);
if (remove) {
list.remove(index);
}
return object;
}
public static int randomElement(IntList list) {
return list.getInt(ThreadLocalRandom.current().nextInt(0, list.size()));
}
public static int randomElement(IntList list, boolean remove) {
int index = ThreadLocalRandom.current().nextInt(0, list.size());
int object = list.getInt(index);
if (remove) {
list.removeInt(index);
}
return object;
}
/**
* Checks if an integer array contains a value