/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package escapegame; /** * * @author 136-pghanem */ public class Inventory { int goldKey, rustedKey, gauze, drill, scalpel, alcohol, remote, clay, lighter, syringe, bunsenburner, lead; int i, j; String[][] inventory = new String[2][5]; public void inv() { for (int row = 0; row < inventory.length; row++) { for (int col = 0; col < inventory[0].length; col++) { inventory[row][col] = " "; } } } public void displayBoard() { System.out.println(" Inventory"); for (int row = 0; row < inventory.length; row++) { for (int col = 0; col < inventory[0].length; col++) { System.out.print("[" + inventory[row][col] + "]"); } System.out.println(); } } public void add(String name) { inventory[i][j] = name; j++; if (j == 4) { j = 0; i++; } } public void remove(String name) { for (int x = 0; x < 5; x++) { for (int y = 0; y < 2; y++) { if (inventory[y][x].equals(name)) { inventory[y][x] = (" "); } } } } public boolean check(String name) { for (int x = 0; x < 5; x++) { for (int y = 0; y < 2; y++) { if (inventory[y][x].equals(name)) { return true; } } } return false; } }