| ||In this problem, you will simulate a program that controls the actions of a progress indicator. The indicator is a single bar character in the middle of the screen with one of 4 states: '|', '-', '\', and '/'. The program is given as a sequence of instructions in the form:|
where <instr> represents one of 4 possible actions, and <secs> is the action's duration in seconds. The action is performed once each second. The 4 possible actions are::
So, the sequence "F03L02" and the starting state of '-' leads to the following sequence: "-|-|\-".
- 'L': Spin left. If the bar is in state '|', it goes to '\'. State '\' goes to '-', '-' goes to '/', and '/' goes to '|'.
- 'R': Spin right. This is the exact opposite of 'L': '\' goes to '|', '|' goes to '/', '/' goes to '-', and '-' goes to '\'.
- 'S': Stay. The bar remains in its current state.
- 'F': Flip. The bar is rotated 90 degrees: '\' becomes '/', '/' becomes '\', '-' becomes '|', and '|' becomes '-'.
You are given a program and a startState. Return a String containing the sequence of states produced by the program. The ith character of the String is the state of the progress indicator after i seconds. At time 0, the indicator is in its initial state, so the first character of the return value is always startState.
|Method signature:||String getMotion(String program, char startState)|
|(be sure your method is public)|
|-||In the examples the character '\' appears as '\\' because of the C++/Java syntax for escaping characters.|
|-||startState will be '|', '-', '\' or '/'.|
|-||program will contain exactly 3*k characters, where k is an integer between 0 and 10, inclusive.|
|-||For each k, the (3*k)-th character in program will be one of 'L', 'R', 'F' or 'S'.|
|-||For each k, the (3*k+1)-th and (3*k+2)-th characters of program will be digits ('0'-'9').|
|This leads to the following sequence of states (below each state is the action performed during that second):|
|Watch out for empty programs!|