Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You may not use Arrays nor ArrayLists for this project. You may not use Arrays nor ArrayLists for this project. You need to implement the

You may not use Arrays nor ArrayLists for this project.

You may not use Arrays nor ArrayLists for this project.

You need to implement the following static methods associated with the DrawingApp class. Feel free to add any private static methods you think can help.

private static boolean isValidColor(char color) - This method returns true if the color parameter corresponds to one of the following characters: 'R' (red), 'G' (green), 'B' (blue), 'Y' (yellow), '*' (black), '.' (white).

public static String getRectangle(int maxRows, int maxCols, char symbol) - This method returns a string with a rectangle that has maxRows and maxCols, using the symbol character. The method will return the special value null (it means nothing or no address) if maxRows or maxCols (or both) are less than 1; in this case no diagram will be generated. The method MUST not rely on System.out.println(). For example, calling DrawingApp.getRectangle(6, 9, '*'); will generate the string:

 ********* ********* ********* ********* ********* ********* 

public static char getRandomColor(Random random) - Using the random.nextInt(6) method call generate a random integer value between 0 and 5. The character to return for a particular integer will be:

0 'R'

1 'G'

2 'B'

3 'Y'

4 '*'

5 '.'

public static String getHorizontalBars(int maxRows, int maxCols, int bars, char color1, char color2, char color3) - This method returns a string with a number of horizontal bars that correspond to the bars parameter. To compute the size of each horizontal bar, divide maxRows by the specified number of bars. The first horizontal bar will use color1, the second color2, and the third color3. If more than 3 bars are present, we will start again with color1. If the computed size for a horizontal bar is less than 1, or any of the colors is invalid, the method will return null and no diagram will be generated. The method MUST not rely on System.out.println(). For example, calling DrawingApp.getHorizontalBars(12, 10, 3, 'R', 'G', 'B'); will generate the string:

 RRRRRRRRRR RRRRRRRRRR RRRRRRRRRR RRRRRRRRRR GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB 

public static String getFlag(int size, char color1, char color2, char color3) - This method returns a string where a triangle appears on the left size of the diagram, followed by horizontal lines. For example, calling DrawingApp.getFlag(9, 'R', '.', 'Y'); will generate the string:

R............................................ RRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY RRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY RRRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY RRRRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY RRRRRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY RRRRRRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY RRRRRRRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY RRRRRRRRR.................................... RRRRRRRRR.................................... RRRRRRRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY RRRRRRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY RRRRRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY RRRRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY RRRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY RRRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY RRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY R............................................ 

The diagram has a number of rows that corresponds to size * 2 and a number of colums that corresponds to size * 5. The first and last row will use color2 (except for the first character that will use color1). The center two rows will use color2 and the rest color3. The triangle will rely on color1 and will have a height corresponding to size * 2. If the size parameter is less than three, the method will return null and will not generate any diagram. For this method you can assume the colors are valid. The method MUST not rely on System.out.println(). public static String getVerticalBars(int maxRows, int maxCols, int bars, char color1, char color2, char color3) - This method returns a string with a number of vertical bars that correspond to the bars parameter. To compute the size of each vertical bar, divide maxCols by the specified number of bars. The first vertical bar will use color1, the second color2, and the third color3. If more than 3 bars are present, we will start again with color1. If the computed size for a vertical bar is less than 1, or any of the colors is invalid, the method will return null and no diagram will be generated. The method MUST not rely on System.out.println(). For example, calling DrawingApp.getVerticalBars(10, 12, 3, 'R', 'G', 'B'); will generate the string:

 RRRRGGGGBBBB RRRRGGGGBBBB RRRRGGGGBBBB RRRRGGGGBBBB RRRRGGGGBBBB RRRRGGGGBBBB RRRRGGGGBBBB RRRRGGGGBBBB RRRRGGGGBBBB RRRRGGGGBBBB 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions