Computer Science Java School question

Started by
0 comments, last by Nairb 17 years, 7 months ago
Hullo, I am in a computer science class at my High School and we are using Java as the language. So far we've made applets and applications using data types, and basic graphics like drawLine, fillRect, drawRect, drawOval, etc. Just recently we've begun loops, and this is a lab we're going to be working on. Image Hosted by ImageShack.us Problem is, I've been messing around and cannot achieve that result. The paper said it is composed of merely straight lines, but it doesn't look like it, and obviously doesn't have an even scale.
Advertisement
Here's what seems to be happening:

Take your first line. Draw it from the bottom left hand corner to the low right. Your next line starts a little to the right (but still on the bottom) of that corner and goes a little higher (but still to the far right). Your next line is a little more right and a little higher. Until eventually your final line is drawn almost at the very right hand corner and all the way to the top.

In psuedocode, it might look something like this:

startX = 0, startY = windowY, endX = windowX, endY = windowY - 10;
for (i = 1 to 50)
{
drawLine(startX, startY, endX, endY)
startX += 10
endY -= 10
}

Hope that helps,
--Brian

This topic is closed to new replies.

Advertisement