void test(){ int correct = 0; int wrong = 0; if(countF("abcdefgf")==2) correct++; else{ wrong++ ; p("countF(abcdefgf) incorrect result"); } if(countF("abcdeg")==0) correct++; else{ wrong++ ; p("countF(abcdefgf) incorrect result"); } if(hasN_Fs("abf,gfdf", 3) == true) correct++; else{ wrong++ ; p("hasN_Fs(\"abf,gfdf\", 3) = incorrect "); } if(hasN_Fs("abf,gfdf", 2) == false) correct++; else{ wrong++ ; p("hasN_Fs(\"abf,gfdf\", 2) = incorrect "); } if( threeTimes("abc").equals("abcabcabc")) correct++; else{ wrong++ ; p("threeTimes(\"abc\") = incorrect "); } if( nTimes("abc",4).equals("abcabcabcabc")) correct++; else{ wrong++ ; p("nTimes(\"abc\", 4) = incorrect "); } if( countMiddleChar("acbcb" ) == 2) correct++; else{ wrong++ ; p("countMiddleChar(\"acbcb\" ) = incorrect "); } if( countMiddleChar("bbbbb" ) == 5) correct++; else{ wrong++ ; p("countMiddleChar(\"bbbbb\" ) = incorrect "); } if( countMiddleChar("xytbtzy" ) == 1) correct++; else{ wrong++ ; p("countMiddleChar(\"xytbtzy\" ) = incorrect "); } if( indexOf("acxb", "x") == "acxb".indexOf("x")) correct++; else{ wrong++ ; p("indexOf(\"acdxb\", \"x\") = incorrect "); } if( indexOf("acxb", "z") == "acxb".indexOf("z")) correct++; else{ wrong++ ; p("indexOf(\"acdxb\", \"z\") = incorrect "); } if( indexOf("acxb", "cx") == "acxb".indexOf("cx")) correct++; else{ wrong++ ; p("indexOf(\"acdxb\", \"cx\") = incorrect "); } if( countChars("momdadmom" , "dad" ) == 1) correct++; else{ wrong++ ; p("countChars(\"momdadmom\" , \"dad\" ) = incorrect "); } if( countChars("foobofoo" , "foo" ) == 2) correct++; else{ wrong++ ; p("countChars(\"foobofoo\" , \"foo\" ) = incorrect "); } if( countChars("foobofoofoo" , "xy" ) == 0) correct++; else{ wrong++ ; p("countChars(\"foobofoo\" , \"xy\" ) = incorrect "); } String[] toA1 = toArray("abc") ; if( toA1[0].equals("a") && toA1[1].equals("b") && toA1[2].equals("c") ) correct++; else{ wrong++ ; p("toArray(\"abc\") incorrect "); } toA1 = toArray("xy") ; if( toA1[0].equals("x") && toA1[1].equals("y") ) correct++; else{ wrong++ ; p("toArray(\"xy\") incorrect "); } toA1 = toArraySansChar("abcadag",'a'); if(toA1[0].equals("b") && toA1[1].equals("c") && toA1[2].equals("d") && toA1[3].equals("g") ) correct++; else{ wrong++ ; p(" toArraySansChar(\"abcadag\",'a') incorrect "); } if(isPalindrome("abba")) correct++; else{ wrong++ ; p(" isPalindrome(\"abba\") incorrect "); } if(isPalindrome("abxba")) correct++; else{ wrong++ ; p(" isPalindrome(\"abxba\") incorrect "); } if(isPalindrome("abxbal") == false) correct++; else{ wrong++ ; p(" isPalindrome(\"abxbal\") incorrect "); } String[] s1 = reversedBy2s("abcdef"); if(s1[0].equals("ef")) correct++; else{ wrong++ ; p("reversedBy2s(\"abcdef\")incorrect "); } if(s1[1].equals("cd")) correct++; else{ wrong++ ; p("reversedBy2s(\"abcdef\")incorrect "); } if(s1[2].equals("ab")) correct++; else{ wrong++ ; p("reversedBy2s(\"abcdef\")incorrect result"); } p("-------------------------"); p("----------results--------"); p("No correct: " + correct); p("No wrong: " + wrong); p("-------------------------"); p("-Getting a perfect score does guarantee not 100, but makes it much more likely"); } void p(String s){ System.out.println(s); } void p(int s){ System.out.println(s); } void p(boolean s){ System.out.println(s); } void p(double s){ System.out.println(s); }