Issue with looping forwards

后端 未结 3 1618
灰色年华
灰色年华 2021-01-26 21:03

so I\'m having an issue with my loops, where the intention is to fill through the whole months before moving to the next line, like so

     January   2000                


        
3条回答
  •  天命终不由人
    2021-01-26 21:28

    Your approach is a bit of a headache. I'm not saying it won't work, but nesting loops like that is too complex.

    You could define a Month class that'll have header() and getLine(int lineNumber) methods.

    You can also have a Quarter class that'll have header() and getLine(int lineNumber) methods. It'll contain three Month objects.

    You can then loop through your Quarter objects (4 in a year) and print the header followed by 6 lines.

提交回复
热议问题