/**
 * Box.java
 * @author Neil Aggarwal 
 */
package com.propfinancing.puzzle.slitherlink;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

/**
 * Base class for a box with lines (Does not have to be rectangular or 2D)
 */
public class Box extends Component {
  /** The serialization version */
  private static final long serialVersionUID = 1L;

  /** An enum for the state of this box */
  public enum STATE { Unknown, Inside, Outside }

  /** Testing a line instance */
  private Line line;
  
  /** The lines for this box */
  private ArrayList<Line> lines;
  /** The state of this box */
  private STATE state = STATE.Unknown;

  /** Test method for GWT */
  public Line getLine() {
    return line;
  }

  /** Default constructor */
  public Box() {
    super();
  }

  /** Get the lines in a new hash set */
  public Collection<Line> getLines() {
    HashSet<Line> set = new HashSet<Line>();
    if( lines != null )
      set.addAll(lines);
    return set;
  }

  /** Get the number of lines in this box */
  public int numLines() {
    if( (lines==null) || lines.isEmpty() )
      return 0;
    return lines.size();
  }

  /**
   * @return the status
   */
  public STATE getState() {
    return state;
  }
}
