Question: Help with java drawing a box. Assignment: Using InteliJ, create a project named Assignment05. Create a new Java class named MainClass. 3) Create the following

Help with java drawing a box.

Assignment:

Using InteliJ, create a project named Assignment05.

Create a new Java class named MainClass. 3) Create the following variables:

public static int boxSize; // size of the box/square

public static int boxMask; // mask for the lines in the box/square

public static int countSpaces; // total count of spaces in the box/square

public static int countLines; // total count of lines in the box/square 4) In MainClass, create the main function to do the following:

Enter an integer number that is the height/width of the box/square drawing (denoted as box in following) as the variable size.

Enter an integer number that has the following bits as flags as the variable mask:

Bit 9 (MSB): draw top line of box

Bit 8: draw bottom line of box

Bit 7: draw vertical center line of box

Bit 6: draw horizontal center line of box

Bit 5: draw left line of box

Bit 4: draw right line of box

Bit 3: draw diagonal line UpperLeft to LowerRight viii. Bit 2: draw diagonal line UpperRight to LowerLeft

Bit 1: draw diagonal lines UpperCenter to CenterLeft to LowerCenter

Bit 0 (LSB): draw diagonal lines UpperCenter to CenterRight to LowerCenter c. Call the DrawBox(size, mask); function 5) In MainClass, create a new function:

public static String DrawBoxRow(int row, int size, int mask)

a. Build a string that contains the row for the specified box of the specified box width size, using the bits in mask to determine what the contents of the box should be. Each location in the line indicates the number of lines in hex that occupy that location:

a space if no lines are cross that location,

1 if one line crosses that location, 2 if two lines, etc.

1

CPT 236 Java Programming Assignment 5

6) In MainClass, create a new function: public static void DrawBox(int size, int mask)

In the outer for loop, loop thru the rows of the box.

In the inner for loop:

Call DrawBoxRow() for current row, then

Count the number of blanks in that line, and total number of lines that cross that row. iii. Accumulate the total number of blanks and lines for the box. iv. Print the string, followed by two tabs, then the number of spaces and number of lines (both of which are for that line).

Additional printing instructions: Generate a 2 row header with the column numbers (zero indexed). Prefix each row with a two digit row number (zero indexed). Draw a box with - for horizontal borders above/below and | vertical borders on sides.

At the end of the drawing of the box, print the size, mask in hex, the cumulative number of spaces, and the cumulative number of lines.

Note no pre-defined contents of the boxs lines are allowed calculate/generate the lines as a function of row and/or function of row&col.

Sample output:

Help with java drawing a box. Assignment: Using InteliJ, create a project

Below is a sample output 1 012345678901234 1 1 2 11 1 5 11 1 1 1 1 9 11 12 11 1 13 111 1 1 Size-15 boxMask-0x03FC countSpaces-120 countLines-120 Below is a sample output 1 012345678901234 1 1 2 11 1 5 11 1 1 1 1 9 11 12 11 1 13 111 1 1 Size-15 boxMask-0x03FC countSpaces-120 countLines-120

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!