@Test public void test() throws InterruptedException { machine.init("aaaaaaaa", ' '); machine.run(); }
@Before public void setUp() throws Exception { machine = new TuringMachine(); machine.addStates( "S", "SEARCH_END", "ADD", "GO_BACK", "CHECK_DIGITS", "CHECK_IF_IT_WAS_LAST_DIGIT", "T", "F"); machine.setStartState("S"); machine.addAcceptState("T"); machine.addRejectState("F"); machine.addTransition("S", 'a', 'A', "SEARCH_END", Movement.Right); machine.addTransition("S", 'A', 'A', "S", Movement.Right); machine.addTransition("S", '#', '#', "CHECK_DIGITS", Movement.Right); machine.addTransition("SEARCH_END", 'A', 'A', "SEARCH_END", Movement.Right); machine.addTransition("SEARCH_END", 'a', 'a', "SEARCH_END", Movement.Right); machine.addTransition("SEARCH_END", ' ', '#', "ADD", Movement.Right); machine.addTransition("SEARCH_END", '#', '#', "ADD", Movement.Right); machine.addTransition("ADD", ' ', '1', "GO_BACK", Movement.Left); machine.addTransition("ADD", '1', '0', "ADD", Movement.Right); machine.addTransition("ADD", '0', '1', "GO_BACK", Movement.Left); machine.addTransition("GO_BACK", '#', '#', "GO_BACK", Movement.Left); machine.addTransition("GO_BACK", 'A', 'A', "GO_BACK", Movement.Left); machine.addTransition("GO_BACK", 'a', 'a', "GO_BACK", Movement.Left); machine.addTransition("GO_BACK", '1', '1', "GO_BACK", Movement.Left); machine.addTransition("GO_BACK", '0', '0', "GO_BACK", Movement.Left); machine.addTransition("GO_BACK", ' ', ' ', "S", Movement.Right); machine.addTransition("CHECK_DIGITS", '0', '0', "CHECK_DIGITS", Movement.Right); machine.addTransition("CHECK_DIGITS", '1', '1', "CHECK_IF_IT_WAS_LAST_DIGIT", Movement.Right); machine.addTransition("CHECK_DIGITS", ' ', ' ', "F", Movement.Right); machine.addTransition("CHECK_IF_IT_WAS_LAST_DIGIT", ' ', ' ', "T", Movement.Right); machine.addTransition("CHECK_IF_IT_WAS_LAST_DIGIT", '0', '0', "F", Movement.Right); machine.addTransition("CHECK_IF_IT_WAS_LAST_DIGIT", '1', '1', "F", Movement.Right); }