Replaced items with inventory. This makes it easier to validate items and add new items, but we need to remove some code repetition.

This commit is contained in:
BuildTools
2017-11-26 14:27:38 +01:00
parent 948b26edf3
commit 63859fe4ae
6 changed files with 316 additions and 220 deletions

View File

@ -3,20 +3,20 @@ import java.util.ArrayList;
public class Trainer {
String name;
private ArrayList<Pokemon> pokemon;
private ArrayList<Item> items;
private Inventory inventory;
public Trainer(String name, ArrayList<Pokemon> pokemon, ArrayList<Item> items) {
public Trainer(String name, ArrayList<Pokemon> pokemon, Inventory inventory) {
this.name = name;
this.pokemon = pokemon;
this.items = items;
this.inventory = inventory;
}
public void setPokemon(ArrayList<Pokemon> pokemon) {
this.pokemon = pokemon;
}
public void setItems(ArrayList<Item> items) {
this.items = items;
public void setInventory(Inventory inventory) {
this.inventory = inventory;
}
public ArrayList<Pokemon> getPokemon() {
@ -43,13 +43,7 @@ public class Trainer {
return pokemon;
}
public ArrayList<Item> getItems() {
ArrayList<Item> items = new ArrayList<Item>();
for (Item item : this.items) {
if (item.getAmount() > 0) {
items.add(item);
}
}
return items;
public Inventory getInventory() {
return this.inventory;
}
}