Problem Statement
Create a class Magnify that contains a method enlarge that is given a String[] image and two integer values horFactor and verFactor, representing the horizontal and vertical scaling factors respectively. It returns a String[] showing the image after horFactor and verFactor have been applied.
The characters in the elements of image each represent a pixel in a rectangular black and white picture, either 'X' or '-'. The elements of image each represent a row in the picture with the pixels given from left to right, and the elements start with the top row and proceed toward the bottom.
Definition
- Class:
- Magnify
- Method:
- enlarge
- Parameters:
- String[], int, int
- Returns:
- String[]
- Method signature:
- String[] enlarge(String[] image, int horFactor, int verFactor)
- (be sure your method is public)
Constraints
- image contains between 1 and 10 elements, inclusive.
- Each element of image contains the same number of characters, between 1 and 10, inclusive.
- Each character in each element of image is 'X' or '-'.
- The absolute value of horFactor is between 1 and 5, inclusive.
- The absolute value of verFactor is between 1 and 5, inclusive.
Examples
{"X"}2
3
Returns: {"XX", "XX", "XX" }This picure was a single pixel. Now it is twice as big in the x-direction, and three times as big in the y-direction.{"X--", "X--", "XXX"}-1
2
Returns: {"--X", "--X", "--X", "--X", "XXX", "XXX" }The original picture has width 3 and height 3 and is an L-shape. After magnification its width is still 3, its height is 6, and the L-shape has been reflected in the x-direction (i.e., about a vertical axis).{"X--", "-X-", "-X-"}2
-3
Returns: {"--XX--", "--XX--", "--XX--", "--XX--", "--XX--", "--XX--", "XX----", "XX----", "XX----" }{"XX-"}1
-1
Returns: {"XX-" }{ "--XX--XX-X", "--XXX----X", "XX---X---X", "---XX-XXXX", "X-XX--XX-X", "---XXXX--X", "--XXX--X-X", "-----X----", "-XXX--XXXX", "------XXX-"}-5
5
Returns: {"XXXXX-----XXXXXXXXXX----------XXXXXXXXXX----------", "XXXXX-----XXXXXXXXXX----------XXXXXXXXXX----------", "XXXXX-----XXXXXXXXXX----------XXXXXXXXXX----------", "XXXXX-----XXXXXXXXXX----------XXXXXXXXXX----------", "XXXXX-----XXXXXXXXXX----------XXXXXXXXXX----------", "XXXXX--------------------XXXXXXXXXXXXXXX----------", "XXXXX--------------------XXXXXXXXXXXXXXX----------", "XXXXX--------------------XXXXXXXXXXXXXXX----------", "XXXXX--------------------XXXXXXXXXXXXXXX----------", "XXXXX--------------------XXXXXXXXXXXXXXX----------", "XXXXX---------------XXXXX---------------XXXXXXXXXX", "XXXXX---------------XXXXX---------------XXXXXXXXXX", "XXXXX---------------XXXXX---------------XXXXXXXXXX", "XXXXX---------------XXXXX---------------XXXXXXXXXX", "XXXXX---------------XXXXX---------------XXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXX-----XXXXXXXXXX---------------", "XXXXXXXXXXXXXXXXXXXX-----XXXXXXXXXX---------------", "XXXXXXXXXXXXXXXXXXXX-----XXXXXXXXXX---------------", "XXXXXXXXXXXXXXXXXXXX-----XXXXXXXXXX---------------", "XXXXXXXXXXXXXXXXXXXX-----XXXXXXXXXX---------------", "XXXXX-----XXXXXXXXXX----------XXXXXXXXXX-----XXXXX", "XXXXX-----XXXXXXXXXX----------XXXXXXXXXX-----XXXXX", "XXXXX-----XXXXXXXXXX----------XXXXXXXXXX-----XXXXX", "XXXXX-----XXXXXXXXXX----------XXXXXXXXXX-----XXXXX", "XXXXX-----XXXXXXXXXX----------XXXXXXXXXX-----XXXXX", "XXXXX----------XXXXXXXXXXXXXXXXXXXX---------------", "XXXXX----------XXXXXXXXXXXXXXXXXXXX---------------", "XXXXX----------XXXXXXXXXXXXXXXXXXXX---------------", "XXXXX----------XXXXXXXXXXXXXXXXXXXX---------------", "XXXXX----------XXXXXXXXXXXXXXXXXXXX---------------", "XXXXX-----XXXXX----------XXXXXXXXXXXXXXX----------", "XXXXX-----XXXXX----------XXXXXXXXXXXXXXX----------", "XXXXX-----XXXXX----------XXXXXXXXXXXXXXX----------", "XXXXX-----XXXXX----------XXXXXXXXXXXXXXX----------", "XXXXX-----XXXXX----------XXXXXXXXXXXXXXX----------", "--------------------XXXXX-------------------------", "--------------------XXXXX-------------------------", "--------------------XXXXX-------------------------", "--------------------XXXXX-------------------------", "--------------------XXXXX-------------------------", "XXXXXXXXXXXXXXXXXXXX----------XXXXXXXXXXXXXXX-----", "XXXXXXXXXXXXXXXXXXXX----------XXXXXXXXXXXXXXX-----", "XXXXXXXXXXXXXXXXXXXX----------XXXXXXXXXXXXXXX-----", "XXXXXXXXXXXXXXXXXXXX----------XXXXXXXXXXXXXXX-----", "XXXXXXXXXXXXXXXXXXXX----------XXXXXXXXXXXXXXX-----", "-----XXXXXXXXXXXXXXX------------------------------", "-----XXXXXXXXXXXXXXX------------------------------", "-----XXXXXXXXXXXXXXX------------------------------", "-----XXXXXXXXXXXXXXX------------------------------", "-----XXXXXXXXXXXXXXX------------------------------" }