making a java inventory

I got super frustrated with Android Studio,  so to make myself not feel like I failure I decided to try and make a workable inventory like you'd use on a classic RPG.  It's not done, but so far this much works!
There are more classes, but I just focused on getting my item inventory to work for now. Here are the three in use.
update: added a useItem&itemHeal to Inventory, i tried making it a part of Item Class, but I couldn't make it work there.
Main Class:

package nellie.tobey.inventory;

public class TestGame {

public TestGame() {
Inventory myInventory = new Inventory();
String printItemName = myInventory.getItemName();
System.out.println("Item = " + printItemName);
System.out.println("Hello");

}

public static void main(String[] args) {
new TestGame();

}

}



Item Class:

package nellie.tobey.inventory;
import java.util.ArrayList;

public class Item {
String name;
int itemHeal;
int itemBoost;
int itemModWeapon;
int itemModArmor;

public Item(String n) {
name = n;

}
}

Inventory Class:


package nellie.tobey.inventory;

import java.util.ArrayList;

public class Inventory {
//item array
ArrayList items = new ArrayList();
ArrayList<String> itemName = new ArrayList();
String printItemName;

public Inventory() {

//weapon array
//ArrayList weapons = new ArrayList<Weapon>();
//armor array
//ArrayList armory = new ArrayList();
//inventory array
//ArrayList backpack = new ArrayList();
//equipment array
//ArrayList equipment = new ArrayList();

items.add(new Item("potion"));
itemName.add("potion");
items.add(new Item("leather sharpener"));
itemName.add("leather sharpener");

}
public String getItemName() {
String printItemName = " ";
for(int i = 0; i < itemName.size(); i++) {
printItemName += ("\n");
printItemName += itemName.get(i);
printItemName += ("\n");
//System.out.println("Item = " + printItemName);
}
return printItemName;
}
public int itemHeal(String itemName) {
int healEffect = 0;
if(itemName == "potion") {
healEffect = 50;
}
return healEffect;
}


public int useItem(int hp, String item) {
int effect = itemHeal(item);
hp = hp + effect;
return hp;

}
//weapons.add(new Weapon("dagger"));
//weapons.add(new Weapon("staff"));

//armory.add(new Armor("silly socks"));
//armory.add(new Armor("cloth shirt"));



}


Comments

Popular posts from this blog

JavaScript Ascii animation with while loops and console.log

playing with trigonometry sin in pygame

JavaScript and a Matrix