public static void main(String[] args) throws Exception { String sequence = "ABCAABBBABACCACC" Base aBase = new Base(); for (int i = 0; i < sequence.length(); i++) { String temp = sequence.substring(i,1); Method method = taggedMethods.get(temp); if (method != null) { // Error handling of invocation exceptions not included method.invoke(aBase); } else { // Unrecognised tag - handle however } } System.out.println(aBase.getState()); }
Base b = new Base(); run(b, "ABCAABBBABACCACC"); System.out.println(b.getState());