|
@ -7,6 +7,8 @@ import java.io.File; |
|
|
import java.nio.file.Files; |
|
|
import java.nio.file.Files; |
|
|
import java.nio.file.Paths; |
|
|
import java.nio.file.Paths; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.HashSet; |
|
|
|
|
|
import java.util.Random; |
|
|
|
|
|
|
|
|
public class Shop { |
|
|
public class Shop { |
|
|
public ArrayList<Item> allItems; |
|
|
public ArrayList<Item> allItems; |
|
@ -14,6 +16,7 @@ public class Shop { |
|
|
|
|
|
|
|
|
public Shop(){ |
|
|
public Shop(){ |
|
|
allItems = loadItems(); |
|
|
allItems = loadItems(); |
|
|
|
|
|
currentShopItems = itemRotation(allItems, 2); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public boolean buy(){ |
|
|
public boolean buy(){ |
|
@ -41,10 +44,18 @@ public class Shop { |
|
|
return arrayList; |
|
|
return arrayList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ArrayList<Item> itemRotation(ArrayList<Item> alleItems, int itemCount){ |
|
|
|
|
|
//ToDo |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
public ArrayList itemRotation(ArrayList<Item> alleItems, int itemCount){ |
|
|
|
|
|
ArrayList arrayList = new ArrayList<Item>(); |
|
|
|
|
|
HashSet<Integer> hashSet = new HashSet<>(); |
|
|
|
|
|
Random random = new Random(); |
|
|
|
|
|
while (hashSet.size() < itemCount){ |
|
|
|
|
|
int rand = random.nextInt(alleItems.size()); |
|
|
|
|
|
if(!hashSet.contains(rand)){ |
|
|
|
|
|
hashSet.add(rand); |
|
|
|
|
|
arrayList.add(alleItems.get(rand)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return arrayList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void getCurrentShopItems(){ |
|
|
public void getCurrentShopItems(){ |
|
|