Write a program to draw alphabet rectangles using given input. In the input the rectangles are given as start-x, start-y, width and height. Eg., [{1,4,2,3}] In this the rectangle starts at (1,4) positions having 2 columns and 3 rows. The rectangle should print alphabets from A-Z and restart from A when it crosses Z. When two rectangles intersect the alphabets should be added and the resultant alphabet should be printed. For eg. 'A' + 'A' = 'B', 'M' + 'C' = 'P', 'X' + 'D' = 'B'
Input (int[][]) | Output |
---|---|
{{0,0,3,4}} | ABC |
{{0,0,6,6}} | ABCDEF |
{{1,0,2,3}} | .AB |
{{0,5,10,1}, {5,0,1,10}} | .....A.... |
{{0,3,4,4}, {5,0,3,3}} | .....ABC |
{{0, 0, 3, 3}, {1, 1, 3, 3}} | ABC. |
class DrawAlphabetRectangles
{ public static void main(String s[])
{
int[][] rects = {{0, 3, 4, 4}, {5, 0, 3, 3}};
drawRects(rects);
}
public static void drawRects(int[][] rects) {
//Write code here to draw alphabet rectangles.
}
//If required write any additional methods here.
}
Topic: Learn Arrays And Loops