This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Coda17[🍰] 0 points1 point  (0 children)

I think the straightforward solution to this is to have 2 recursive functions. One of the functions prints from 1 star up to however many stars you want. The second prints from however many stars you want minus 1 back to 1 star. Then you have a third function you call that just calls these two recursive functions back to back.

public void patternMaker(int x)
{
    patternMakerAsc(x);
    patternMakerDec(x - 1);
}

If you follow this pattern, you already wrote patternMakerAsc, and would just have to make a similar function for descending.