Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Help > Re: Need some h...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 9 Topic 15986 of 16204
Post > Topic >>

Re: Need some help.....

by RedGrittyBrick <RedGrittyBrick@[EMAIL PROTECTED] > Apr 18, 2008 at 10:47 AM

TheBigPJ wrote:
>   //Fill in the appropiate spot
>   if(i == 1)
>   {
>       g.fillOval(2,62,12,12);
>   }
>   else if(i == 2)
>   {
>       g.fillOval(250,4,12,12);
>   }
....
>   else if(i == 16)
>   {
>       g.fillOval(137,455,12,12);
>   }

A couple of observations:

1)
I'd use switch instead of long else if chains.
    switch(i) {
      case 1: g.fillOval(2,62,12,12); break;
      case 2: g.fillOval(250,4,12,12); break;
      ...
      case 16: g.fillOval(137,455,12,12);
    }

2)
I'd define the coordinates in a Point[] at the start of the program so 
that I could replace the above with the single line
     g.fillOval(point[i].x, point[i].y, RADIUS,RADIUS);

The aim being to move long lists of constants somewhere where they don't 
obscure the control structures. This helps keep methods short and
readable.


I would have tried to work out what is causing the problem you were 
asking about, but you didn't supply an SSCCE.

-- 
RGB
 




 9 Posts in Topic:
Need some help.....
TheBigPJ <TheBigPJ@[EM  2008-04-17 09:36:46 
Re: Need some help.....
TheBigPJ <TheBigPJ@[EM  2008-04-17 09:38:52 
Re: Need some help.....
Knute Johnson <nospam@  2008-04-17 16:51:45 
Re: Need some help.....
Roedy Green <see_websi  2008-04-18 01:51:34 
Re: Need some help.....
Chase Preuninger <chas  2008-04-17 19:52:23 
Re: Need some help.....
Knute Johnson <nospam@  2008-04-17 20:35:38 
Re: Need some help.....
RedGrittyBrick <RedGri  2008-04-18 10:47:59 
Re: Need some help.....
TheBigPJ <TheBigPJ@[EM  2008-04-18 10:56:31 
Re: Need some help.....
Roedy Green <see_websi  2008-04-18 19:16:21 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 6:42:47 CDT 2008.