Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Concentric Shapes Trouble

807589Sep 25 2008 — edited Sep 28 2008
Hi all,

I'm new to this forum. This is my first post. I'm working on an assignment for my Intro to Java class and need some help. I wrote the program already, and I'm fairly sure it should work, but it won't show the picture when I try to run it.

The program is supposed to draw concentric octogons, each larger than the previous. This is due at midnight tonight, so any help is needed ASAP.

Thanks a lot. Here is my code.


import java.awt.Color;

public class filename
{
public static void main(String[] args)
{

Picture pict = new Picture (640, 480);
Turtle turtle1 = new Turtle(pict);

int count;
int length;

//center the turtle
turtle1.penUp();
turtle1.turn(-90);
turtle1.forward(25);
turtle1.turn(-90);
turtle1.forward(20);
turtle1.turn(180);
turtle1.penDown();

length = 10;

count = 0;
while (count < 10);

{
turtle1.drawOctogonWithColor ( (length) , Color.red );
turtle1.penUp();
turtle1.turn(-90);
turtle1.forward(5);
turtle1.turn (-90);
turtle1.forward(5);
turtle1.turn(180);
turtle1.penDown();

count++;
length = length + 5;
}


pict.show();

}
}





Also, the method for drawOctogonWithColor is defined in another file. Here is the code for that method:



public void drawOctogonWithColor (int length, Color colorParam)
{
int loopCount;

this.setPenColor (colorParam);

loopCount = 0;
while (loopCount < 8)
{
this.forward(length);
this.turn (45);
loopCount++;
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 26 2008
Added on Sep 25 2008
35 comments
359 views