public void displayAllItems() { for (Item item : items) { System.out.println(item.getItemName() + ": " + item.displayProductInfo()); } }
public void setItemsParent(String parentItem) { for (Item item : items) { if (item.getItemName().equals(parentItem)) { parent = item; } } }
public ItemBuilder(String rootName) { root = new Item(rootName); addItemToArrayList(root); current = root; parent = root; // Store the parent for the Item object root.addItemInformation("Parent", parent.getItemName()); }
public Item getItemByName(String itemToGet) { Item itemToReturn = null; for (Item item : items) { if (item.getItemName().equals(itemToGet)) { itemToReturn = item; } } return itemToReturn; }
public void addChild(String child) { Item childNode = new Item(child); addItemToArrayList(childNode); current.add(childNode); parent = current; current = childNode; // Store the parent for the Item object childNode.addItemInformation("Parent", parent.getItemName()); }
public void addSibling(String sibling) { Item siblingNode = new Item(sibling); addItemToArrayList(siblingNode); // Adding a child node to the parent Item parent.add(siblingNode); current = siblingNode; // Store the parent for the Item object siblingNode.addItemInformation("Parent", parent.getItemName()); }
public void editThisItem(String itemName) { for (Item item : items) { if (item.getItemName().equals(itemName)) { current = item; // Gets the name of the stored parent object // and passes it so that parent can be set // as the parent in the ItemBuilder setItemsParent(current.getItemInformation("Parent")); } } }