/** * Implement the method below that takes a String str as input * argument and returns string after removing all dupli
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
/** * Implement the method below that takes a String str as input * argument and returns string after removing all dupli
Please do the implementation below the where that wrote "Yourimplementation" and write the same class as the pictures donot change anything thanks and there's information below classabout what you should write thanks and that's the Junit testproject all of the task should be pass thanks and please provideyour screen shot of your code that all of the task are passed withthe my junit test that i provided for you
/** * Implement the method below that takes a String str as input * argument and returns string after removing all duplicates * characters from the input string. * * The order of characters in the returned string is not * important, so the strings "ECSLAB" and "CELABS" are same. * * * You can assume that the input String is not null and contains at * least 2 two characters. * * * For example: * * * * if str = * if str = "EECCCCCSSSLLLLLAB" then return "ABCELS" "0001110001001" then return "01" * if str "cvvvvaaabcca" then return "abcv." * if str = "LabTtttEeeeSsssT" then return "ELSTabest" * * * @param str : input string * @return string after removing all duplicates characters from the * input string */ public static String removeDuplicatesChar(String str) { /* Your implementation of this method starts here. * Recall that : * 1. No System.out.println statements should appear here. * Instead, you need to return the result. * 2. No Scanner operations should appear here (e.g., input.nextInt()). Instead, refer to the input parameters of this method. * */
aTest public void test_00_removeDuplicatesChar() { } } final String str= "EECCCCCSSSLLLLLAB"; char [] cleanstr = char [] expect = "ECSLAB".toCharArray(); Arrays.sort (expect); Arrays.sort(cleanstr); String str1 = String.format("\nTest removeDuplicates Char fail for %s. Returned ( %s )," + " but correct is ( %s\n", str,StringUtility.removeDuplicatesChar(str), "ECSLAB" ); assertTrue (str1, Arrays.equals(cleanstr, expect)); aTest public void test_01_removeDuplicates Char() { StringUtility.removeDuplicatesChar (str).toCharArray(); } final String str= "0001110001001"; char [] cleanstr = StringUtility.removeDuplicatesChar(str).toCharArray(); char [] expect = "01".toCharArray(); Arrays.sort (expect); Arrays.sort(cleanstr); String str1 = String.format("\nTest removeDuplicatesChar fail for %s. Returned ( %s )," + " but correct is ( %s\n", str, StringUtility.removeDuplicatesChar(str), "01" ); assertTrue (str1, Arrays.equals(cleanstr, expect )); aTest public void test_02_removeDuplicatesChar() { final String str= "AAAABBBCCC"; char [] cleanstr = StringUtility.removeDuplicates Char (str).toCharArray(); char [] expect = "CBA".toCharArray(); Arrays.sort (expect); Arrays.sort(cleanstr); String str1 = String.format("\nTest removeDuplicatesChar fail for %s. Returned ( %s ), but correct is ( %s )\n", str,cleanstr, expect ); assertTrue (str1, Arrays.equals(cleanstr, expect));