|
|
@@ -0,0 +1,24 @@
|
|
|
+package com.happy.Until;
|
|
|
+
|
|
|
+import com.happy.Model.Hotel;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Random;
|
|
|
+
|
|
|
+public class RandomSelection {
|
|
|
+
|
|
|
+ public static List<Hotel> getList(List<Hotel> list, int numberOfElementsToSelect){
|
|
|
+ List<Hotel> selectedElements = new ArrayList<>();
|
|
|
+ Random random = new Random();
|
|
|
+
|
|
|
+ for (int i = 0; i < numberOfElementsToSelect; i++) {
|
|
|
+ int randomIndex = random.nextInt(list.size());
|
|
|
+ selectedElements.add(list.get(randomIndex));
|
|
|
+ list.remove(randomIndex);
|
|
|
+ }
|
|
|
+ return selectedElements;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|