Draw a stair using Java
<p>I am drawing a stair on Java JPanel from <code>(0,0)</code> to the coordinate <code>(JComponent.getWidth(), JComponent.getHeight())</code>.<br>
The horizontal and vertical length will stay the same depends on the constant <code>NUM_STAIRS</code>.<br>
The initial drawing will be a horizontal line. I am guessing this will use while and if statements (probably nested) but I am not sure how to produce this algorithm.</p>

<p>My thinking:</p>

<p>Version 1:<br>
Firstly draw a horizontal line of <code>JComponent.getWidth()/NUM_STAIRS</code> in length when the y-axis meets the requirement of<br>
<code>(y=n x JComponent.getHeight()/NUM_STAIRS, where 0&lt; n&lt;=NUM_STAIRS)</code>.<br>
Remember the endpoint coordinates of the drawn line, draw the vertical line of <code>JComponent.getHeight()/NUM_STAIRS</code><br>
in length and then draw the next horizontal line at the endpoint's x coordinate of the same length at<br>
<code>y = 1 x JComponent.getHeight()/NUM_STAIRS.</code><br>
Repeat this action until y=JComponent.getHeight().</p>

<p>Version 2:<br>
Do 2 loops, draw the horizontal lines and vertical lines separately, idea will be similar with the Version 1. But I am confused about how to write this idea into some code.</p>

<p>Could someone help me out please? Thanks.</p>
