refactored automaton class, created buildautomaton class with the method to create an automaton for union