Below is the syntax highlighted version of State2.java.
// Donna Gabai, dgabai, P01 // fall09 exam 2 // State object class for DFA.java // dependencies: ST public class State2{ // instance variables private String type; private ST<Character, Integer> state; // constructor sets up the instance variables public State2(String type, ST<Character, Integer> st) { this.type = type; this.state = new ST<Character, Integer>(); // copy all the states from the argument symbol table // into the instance variable symbol table for (char i : st) { int n = st.get(i); state.put(i, n); } } // return type of this state public String type() { return this.type; } // transition to next state based on input char public int next(char c) { int n; if (state.get(c) != null) n = state.get(c); else n = state.get('$'); return n; } }