Problem Statement
You are converting old code for a new compiler version. Each "->" string should be replaced by ".", but this replacement shouldn't be done inside comments. A comment is a string that starts with "//" and terminates at the end of the line.
You will be given a String[] program containing the old code. Return a String[] containing the converted version of the code.
Definition
- Class:
- AccessChanger
- Method:
- convert
- Parameters:
- String[]
- Returns:
- String[]
- Method signature:
- String[] convert(String[] program)
- (be sure your method is public)
Constraints
- program will have between 1 and 50 elements, inclusive.
- Each element of program will contain between 1 and 50 characters, inclusive.
- Each character in program will have ASCII value between 32 and 127, inclusive.
Examples
{"Test* t = new Test();", "t->a = 1;", "t->b = 2;", "t->go(); // a=1, b=2 --> a=2, b=3"}Returns: {"Test* t = new Test();", "t.a = 1;", "t.b = 2;", "t.go(); // a=1, b=2 --> a=2, b=3" }{"---> // the arrow --->", "---", "> // the parted arrow"}Returns: {"--. // the arrow --->", "---", "> // the parted arrow" }{"->-> // two successive arrows ->->"}Returns: {".. // two successive arrows ->->" }