/**
 *  TEDState.java 
 *
 *  Copyright 2005 Ben Pfistner and Jason Emmons
 *
 *  This class represents a single state of the Turing Machine. 
 *  It holds a collection of all the transitions which transition away from this state.
 *
 */

import java.util.*;

class TEDState
{
	//This holds all of the 5tuples that transition from this state.
	ArrayList tupleList;
	
	/**
	 *  Constructor
	 *
	 */
	public TEDState()
	{
		tupleList = new ArrayList();
	}	
	
	/**
	 *  addTuple
	 *
	 *  This method adds a 5tuple to the tupleList
	 *
	 *  @param tuple the tuple to be added
	 *
	 */
	public void addTuple(TED5tuple tuple)
	{
		tupleList.add(tuple);	
	}
	
	/**
	 *  getTuple
	 *
	 *  This method returns a 5tuple which matches the current state and readChar
	 *
	 *  @param readChar the character read off the tape
	 *
	 *  @return the matching 5tuple
	 *
	 */
	public TED5tuple getTuple(char readChar)
	{
		Iterator iter = tupleList.iterator();
		
		while(iter.hasNext())
		{
			TED5tuple tuple = (TED5tuple)iter.next();
			if(tuple.getReadChar() == readChar)
			{
				return tuple;
			}
		}
		
		return null;	
		
	}
	
	public ArrayList getArray()
	{
		return tupleList;	
	}

	public static void main(String [] args)
	{
		TEDState foo = new TEDState();
		
		TED5tuple a = new TED5tuple();
		a.setInitialState("5");
		a.setFinalState("10");
		a.setReadChar('a');
		a.setWriteChar('c');
		a.setDirection('L');
		
		TED5tuple b = new TED5tuple();
		b.setInitialState("5");
		b.setFinalState("10");
		b.setReadChar('b');
		b.setWriteChar('b');
		b.setDirection('L');
		
		foo.addTuple(a);
		foo.addTuple(b);
		
	}
}