Class NodeValue

java.lang.Object
kkchengaf.EnchantmentOrder.NodeValue

public class NodeValue extends Object
Class that store information of a tree node, cost: the cost of enchantment weight, prior: the cost of prior work penalty, enchant: the mapping of id:lv of the enchantments of this node
  • Constructor Details

    • NodeValue

      public NodeValue()
      default constructor
    • NodeValue

      public NodeValue(Integer c, Integer h, Integer p, HashMap<Integer,Integer> e)
      construct the NodeValue
      Parameters:
      c - , the equivalent enchantment weight
      h - , the height of the node, 0 for leaves
      p - , the prior work penalty
      e - , the HashMap Integer,Integer of the enchantments
  • Method Details

    • equals

      public boolean equals(Object obj)
      Check if two node values are equal
      Overrides:
      equals in class Object
      Parameters:
      obj - , object to be compared
      Returns:
      boolean
    • setCost

      public void setCost(Integer cost)
      set the equivalent cost of the enchantments
      Parameters:
      cost - , Integer
    • setEnchant

      public void setEnchant(HashMap<Integer,Integer> enchant)
      set the enchantments
      Parameters:
      enchant - , Hashmap
    • setHeight

      public void setHeight(Integer h)
      set the height
      Parameters:
      h - , Integer
    • setPrior

      public void setPrior(Integer prior)
      set the prior work penalty
      Parameters:
      prior - , Integer
    • getCost

      public Integer getCost()
      get the equivalent cost of the enchantments
      Returns:
      Integer
    • getHeight

      public Integer getHeight()
      get the height, 0 for leaves
      Returns:
      Integer
    • getPrior

      public Integer getPrior()
      get the prior work penalty, non 0 for non leaf nodes
      Returns:
      Integer
    • getEnchant

      public HashMap<Integer,Integer> getEnchant()
      get the enchantments
      Returns:
      HashMap
    • isItem

      public boolean isItem()
      check whether this item is non book
      Returns:
      boolean
    • toString

      public String toString()
      to String value, return "" if enchantment is null, return "item" for the item to be combined, return the enchantments for the books
      Overrides:
      toString in class Object
      Returns:
      String