Write a method called prettyOutput for the maze where you output it in a format that is easier to visualize. For this, print a border around the table, like a + in each corner, a row of minuses above and below the table, and a | at the beginning and at the end of each row. Then when you print the elements, check if the value is equal to 0, and if it is, print a couple of spaces, if it's equal to 1, then print a * character followed by a space, and if it's equal to 2, print a period (.) followed by a space. How do I add the bolded part in the method, please see what I have so far below: public void prettyOutput() { System.out.print("+"); for (int i=0; i <= columns*2; ++i) { System.out.print("-"); } System.out.println("+"); for (int r=0; r < maze.length; ++r){ System.out.print("| "); for (int c=0; c < maze[r].length; ++c) { System.out.printf(maze[r][c]+" "); } System.out.println("|"); } System.out.print("+"); for (int i=0; i <= columns*2; ++i){ System.out.print("-"); } System.out.println("+"); } Subject: Java Programming
Write a method called prettyOutput for the maze where you output it in a format that is easier to
visualize. For this, print a border around the table, like a + in each corner, a row of minuses above and below
the table, and a | at the beginning and at the end of each row. Then when you print the elements, check if the
value is equal to 0, and if it is, print a couple of spaces, if it's equal to 1, then print a * character followed by a
space, and if it's equal to 2, print a period (.) followed by a space.
How do I add the bolded part in the method, please see what I have so far below:
public void prettyOutput()
{
System.out.print("+");
for (int i=0; i <= columns*2; ++i)
{
System.out.print("-");
}
System.out.println("+");
for (int r=0; r < maze.length; ++r){
System.out.print("| ");
for (int c=0; c < maze[r].length; ++c)
{
System.out.printf(maze[r][c]+" ");
}
System.out.println("|");
}
System.out.print("+");
for (int i=0; i <= columns*2; ++i){
System.out.print("-");
}
System.out.println("+");
}
Subject: Java Programming
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images