Exemplo n.º 1
0
  public void displayAllItems() {

    for (Item item : items) {

      System.out.println(item.getItemName() + ": " + item.displayProductInfo());
    }
  }
Exemplo n.º 2
0
  public void setItemsParent(String parentItem) {

    for (Item item : items) {

      if (item.getItemName().equals(parentItem)) {

        parent = item;
      }
    }
  }
Exemplo n.º 3
0
  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());
  }
Exemplo n.º 4
0
  public Item getItemByName(String itemToGet) {

    Item itemToReturn = null;

    for (Item item : items) {

      if (item.getItemName().equals(itemToGet)) {

        itemToReturn = item;
      }
    }

    return itemToReturn;
  }
Exemplo n.º 5
0
  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());
  }
Exemplo n.º 6
0
  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());
  }
Exemplo n.º 7
0
  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"));
      }
    }
  }