2

I have code that has multiple methods and we're suppose to call said methods to help us format an image made from characters. The image is a cake and uses characters like "=", "\", "^" and "/" among others I have yet to get too. Anyways using odd user input between 3 and 9 (3,5,7,9), we're suppose to format it so it prints out the other method and then the one before it. So If one method prints out "[|_______||_______||_______|]" and the other one prints out "[|___||_______||_______|____|]" with it's size varying with user input. If input is 3 it's suppose to print out both methods once as the hint was that it uses half the user input to decide how often to print something. The problem goes when I go beyond 3 to 5 or 7 as I get something like

/^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\ 
[|_______||_______||_______||_______||_______|] 
[|_______||_______||_______||_______||_______|] 
[|___||_______||_______||_______||_______|___|] 
[|_______||_______||_______||_______||_______|] 
[|_______||_______||_______||_______||_______|] 
[|___||_______||_______||_______||_______|___|] 
\=============================================/

It's suppose to print one then the other, not two at once. Not only that but in total the methods are only suppose to print out 4 times if it's 5 so I'm suppose to get something like this instead. I think it's how I formatted my for loops for that method but I could be wrong, thank you in advance to anyone willing to help.

/^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\ 
[|_______||_______||_______||_______||_______|]
[|___||_______||_______||_______||_______|___|]
[|_______||_______||_______||_______||_______|]
[|___||_______||_______||_______||_______|___|] 
\=============================================/

My "drawFullBrick" method prints out the [|_______||_______||_______||_______||_______|] part while the "drawHalfBrick" prints out the [|___||_______||_______||_______||_______|___|] part

public static void drawBrickStack (int sizeParam) {
    System.out.print("/");
    for (int count = 0; count < sizeParam * 9; count++)
        System.out.print("^");
    System.out.print("\\ \n");

    for (int count = 0; count < sizeParam/2; count++)
    { 
        for (int nestedCount = 0; nestedCount < sizeParam/2; nestedCount++)
        {
        drawFullBrickLine(sizeParam);
    }
        drawHalfBrickLine(sizeParam);
    }
  • 2
    You might want to use a [debugger](https://stackoverflow.com/questions/25385173/what-is-a-debugger-and-how-can-it-help-me-diagnose-problems) for that or look at [How to debug small programs](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/) – Andreas Apr 05 '19 at 03:17
  • 2
    Why do you think you need a nested loop? I think just one loop should be enough. – Dawood ibn Kareem Apr 05 '19 at 03:24
  • 1
    Actually yeah I just realized what you said. I figured I could make it go one or the other with a nested loop when really all I needed was one for loop with brackets since I could put the two methods in their. I've solved it now so thank you very much for the tip. Shame I couldn't notice it earlier. – Confused Student Apr 05 '19 at 03:33

0 Answers0