View Single Post
  #4 (permalink)  
Old 10-08-2008, 01:32 AM
Norm's Avatar
Norm Norm is offline
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Norm is on a distinguished road
You're not going to make ANY progress programming without knowing how to debug your program. NONE! 99.9% of programs have bugs.
Some ideas:
First read the API doc for Graphics to see which draw methods to use. drawOval vs drawArc for example.
Use different colors for each drawing to see where each is being drawn. Your comments misplace where the draws occur.
Add println() of the different int variables you are using to see if their values make sense.
Figure out how to draw one design at a time, then make it a method and pass it the x,y location where you where want it to draw, instead of writing the same code 3 times.

Add comments to describe why the values of 45 and 150 are used.
It'd be better if those values were defined as variables with descriptive names:
final int DivFactor = 45; then use DivFactor in your code to doc what you are doing.

Add the <APPLET tag to be used to execute the program as a comment at the front of your program to show how to use it.
BTW with the <APPLET tag in your code you can do:
appletviewer test1.java
You wouldn't need a separate HTML page.

Last edited by Norm : 10-08-2008 at 01:35 AM.
Reply With Quote