I have to complete a program where the criteria is as follows:
- Objects created from the Code class have one parameter: (String code)
- The Code class has two methods: hide(int p1, int p2) and recover(int p1, int p2).
- Hiding replaces all of the characters within the index range of p1 to p2 with “XXXX…”
- Recovering replaces all of the X’es with the original text.
I am completely stumped as to how to approach this. I have tried multiple approaches, but I always wind up overcomplicating it and confusing myself.
Any ideas?
You can use StringBuilder class and its method replace