Problem Statement
****************** THIS IS A JAVA ONLY PROBLEM ******************** Given the following two dimensional matrix : [a][b][c] [d][e][f] Manipulate the elements of this two dimensional matrix of strings, by either : - transposing - rotating -- x > 0 (rotate clockwise) -- x < 0 (rotate counterclockwise) - shifting the elements horizontally -- x > 0 (shift right) -- x < 0 (shift left) - shifting the elements vertically -- x > 0 (shift up) -- x < 0 (shift down) Your program will take as input an ArrayList of steps designating how the matrix should be manipulated. The ArrayList will consist of Characters and Integers representing the case sensitive Character command and Integer iterations(optional) : transpose - 't' (no iteration argument) rotate - 'r' (Integer) shift hor - 'h' (Integer) shift ver - 'v' (Integer) Here is the method signature : public ArrayList juggle(ArrayList steps); We will check to make sure the input to this problem is valid. (ie Character, Integer, Character, Integer etc) If you are not familiar with java.util.ArrayList, they are used to hold objects, such as Integers and Strings. ArrayList.add(obj) will add obj to the end of an ArrayList. ArrayList.get(n) will return the nth object. ArrayList.remove(n) will remove the nth object and shift forward all objects behind it. ArrayList.size() returns the number of objects in the ArrayList. Here is the example input (ArrayList) : [v, 5, r, 1, h, -1, t, r, -6, h, 2] Here is the example output (ArrayList) : [[b, a, c], [e, d, f]] (your program should only return the final matrix in an ArrayList of ArrayLists of Strings) Here is the transition : original : [a][b][c] [d][e][f] shifted vertically : 5 : [d][e][f] [a][b][c] rotated : 1 : [a][d] [b][e] [c][f] shifted horizontally : -1 : [d][a] [e][b] [f][c] transposed : [d][e][f] [a][b][c] rotated : -6 : [c][b][a] [f][e][d] shifted horizontally : 2 : [b][a][c] [e][d][f]
Definition
- Class:
- Matrix
- Method:
- juggle
- Parameters:
- ArrayList
- Returns:
- ArrayList
- Method signature:
- ArrayList juggle(ArrayList param0)
- (be sure your method is public)
Constraints
Examples
No public sample cases were explicitly marked for this problem in the original data.