0

Test Class

 @Test
    public void testCharRemover() {
        TextModifier remover = new CharRemover('x');
        StringBuilder buff = new StringBuilder("a bx xd xx");
        remover.modifyText(buff);
        Assert.assertEquals("a b d ", buff.toString());
    }

-------------------------------------------------------

/**
 * Removes all occurrences of the character passed to the constructor
 * from the input when {@link TextModifier#modifyText(StringBuilder)}
 * is called.
 */
public class CharRemover implements TextModifier {
    // TODO

    public CharRemover(char charToRemove) {
        // TODO
    }

----------------------------------------------------

I am confused where to start. I know that I have to take in the string and remove the "x" and then return the string. But thats about it.

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by Taywin
0

What you need to do are obvious and stated in the CharRemover class.

1)You need to declare local variables for the class. In this case, you need at least one variable type char which will hold the incoming value from the constructor.
2)You need to implement a method modifyText() that takes in StringBuilder class. Inside the method, you need to modify the passed in StringBuilder variable.

That's all you need to do from the requirement.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.