@Test public void test_00_compressString() { String inputStr = "bbbcfreb$b"; String expected = "b3c1f1rlelbl$1b1"; Strin
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
@Test public void test_00_compressString() { String inputStr = "bbbcfreb$b"; String expected = "b3c1f1rlelbl$1b1"; Strin
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
@Test public void test_00_compressString() { String inputStr = "bbbcfreb$b"; String expected = "b3c1f1rlelbl$1b1"; String result = StringUtility.compressString (inputStr); String error = String.format("error on compressString, expected %s, but returned %s", expected, result); assertTrue (error, expected.equals(result)); } @Test public void test_01_compressString() } String inputStr = "bbbcffffreb$b"; String expected = "b3c1f4r1e1b1$1b1"; String result StringUtility.compressString (inputStr); String error = String.format("error on compressString, expected %s, but returned %s", expected, result); assertTrue (error, expected.equals(result)); } @Test public void test_02_compressString() { String inputStr = String expected = String result = StringUtility.compressString (inputStr); String error = String.format("error on compressString, expected %s, but returned %s", expected, result); "SHOWSHOWSHOWSHOWCASECASE"; "S1H101W1S1H101W1S1H101W1S1H101W1C1A1S1E1C1A1S1E1";
/** * <p> Write a compressString method that * compression long String {@code str} that contain many adjacent equal characters * (but no digits). * <p> For example: </p> * * * * compressString("") return "" * compressString("bbbcfreb$b") * compressString("bbbrrraaaaaazzzz") * * </pre> * <pre> * * @param inputStr : * * @pre.. * , empty string return "b3c1flrlelbl$1b1" return "b3r3a6z4" string to be compressed, {@code str} is not null Precondition: s does not contain a digit in '0'.. '9¹. the compressed version of long string as explained above * @return * * * * * */ public static String compressString (String inputStr) { /* 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. * */