
public class BTNodeImpl
implements BTNode {
	
	private int m_data;
	private BTNode m_left;
	private BTNode m_right;
	
	public BTNodeImpl(int data) {
		m_data = data;
		m_left = m_right = null;
	}
	
	public int getData() {
		return m_data;
	}

	public void setData(int data) {
		m_data = data;
	}

	public BTNode getLeft() {
		return m_left;
	}

	public void setLeft(BTNode node) {
		m_left = node;
	}

	public BTNode getRight() {
		return m_right;
	}

	public void setRight(BTNode node) {
		m_right = node;
	}

	public void addInOrder(int data) {
		if (data < m_data) {
			if (m_left == null) {
				m_left = new BTNodeImpl(data);
			}
			else {
				m_left.addInOrder(data);   // recursively adds the node to the left if it's <
			}
		}
		else {
			if (m_right == null) {
				m_right = new BTNodeImpl(data);
			}
			else {
				m_right.addInOrder(data);   // otherwise, recursively adds the node to the right 
			}
		}
	}

	public boolean containedIn(int data) {
		if (m_data == data) {
			return (true);
		}
		else {
			if (data < m_data) {
				if (m_left != null) 
					return (m_left.containedIn(data));
			}
			else {
				if (m_right != null)
					return (m_right.containedIn(data));
			}
		}
		return (false);
	}

	
}

