Question: public class Lab3_PartII { static final int ROWS = 5; public static void main(String[] args) { System.out.println(Shape 1:); printShape1(); System.out.println(Shape 4:); printShape4(); } static void

 public class Lab3_PartII { static final int ROWS = 5; public

public class Lab3_PartII {

static final int ROWS = 5;

public static void main(String[] args) {

System.out.println("Shape 1:");

printShape1();

System.out.println("Shape 4:");

printShape4();

}

static void printShape1() {

// print rows

for (int i = 1; i

// print 5 '*' characters.

printRowOfChars(5,'*');

System.out.println();

}

}

static void printShape4() {

// print rows

for (int i = 1; i

// It's own method because it's just printing a single character

// a given number of times.

printRowOfChars((ROWS - i) * 2, ' ');

// Kept here becuase it isn't a single character, but a pare of two

// different characters.

for (int j = 1; j

System.out.print(i);

System.out.print(" ");

}

System.out.println();

}

}

// Prints a row of a single character.

static void printRowOfChars(int count, char what) {

for(int i = 0; i

System.out.print(what);

}

}

Part II: (Class name: Lab3_PartII) 1. This part is intentionally a bit less specific as the objective is for you to minimize the unnecessary redundancy in Lab2 by generalizing the loop redundancy - where possible - by encapsulating the "inner loops" (within the shape drawing functions) into their own functions. Just like back in Labl, some functionally will be unique enough to keep everything together in a single function, other places may have the same reoccurring structures which could be broken out into their own slapper functions. In short: Remove the inner-loops from your Lab2 Solution and, WHERE POSSIBLE, replace them with calls to functions/methods, passing any necessary parameters. (It's best to see the attached example for an example). And yes... as is true with MOST REAL-WORLD PROGRAMMING, this part is a bit more "subjective" and there is not "one correct way" of breaking things apart. Part II: (Class name: Lab3_PartII) 1. This part is intentionally a bit less specific as the objective is for you to minimize the unnecessary redundancy in Lab2 by generalizing the loop redundancy - where possible - by encapsulating the "inner loops" (within the shape drawing functions) into their own functions. Just like back in Labl, some functionally will be unique enough to keep everything together in a single function, other places may have the same reoccurring structures which could be broken out into their own slapper functions. In short: Remove the inner-loops from your Lab2 Solution and, WHERE POSSIBLE, replace them with calls to functions/methods, passing any necessary parameters. (It's best to see the attached example for an example). And yes... as is true with MOST REAL-WORLD PROGRAMMING, this part is a bit more "subjective" and there is not "one correct way" of breaking things apart

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!