Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By awinston

Thread: There Must Be Another Way!

  1. #1
    Delinitor is offline Super n00b
    Join Date
    Jun 2012
    Location
    The Internetz
    Posts
    17
    Rep Power
    0

    Smile There Must Be Another Way!

    Is there an easier way of doing this? The large number of if() statements is causing me to doubt myself ...

    Java Code:
         
    if(updateLoop==points[1]){
    	number1 += 1;
    }
    if(updateLoop2==points[2]){
    	number1 += 1;
    }
    if(updateLoop2==points[3]){
    	number1 += 1;
    }
    if(updateLoop2==points[4]){
    	number1 += 1;
    }
    if(updateLoop2==points[5]){
    	number1 += 1;
    }
    etc();
    Thanks!
    Last edited by Delinitor; 07-10-2012 at 06:44 PM. Reason: Formatting

  2. #2
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    2

    Default Re: There Must Be Another Way!

    How about:

    Java Code:
    for(int i = 1; i < 6; i++)
    {
          if(updateLoop2 == points[i])
                number1++;
    }
    Last edited by awinston; 07-10-2012 at 07:11 PM. Reason: variable name
    Fubarable likes this.

  3. #3
    Delinitor is offline Super n00b
    Join Date
    Jun 2012
    Location
    The Internetz
    Posts
    17
    Rep Power
    0

    Default Re: There Must Be Another Way!

    Quote Originally Posted by awinston View Post
    How about:

    Java Code:
    for(int i = 1; i < 6; i++)
    {
          if(updateLoop2 == points[i])
                number1++;
    }
    Thanks! This is exactly what I was looking for.

  4. #4
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    2

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •