Thread: Explaining <= statements?

Results 1 to 9 of 9
  1. #1 Explaining <= statements? 
    Member

    Join Date
    Aug 2009
    Age
    28
    Posts
    513
    Thanks given
    8
    Thanks received
    2
    Rep Power
    0
    Can someone explain a <= statement thing too me? Like what it does. Like the difference between < and = and <=?

    For example, what does this mean:
    Code:
    if(playerRights >= 2)
    Reply With Quote  
     

  2. #2  
    Community Veteran

    Songoty's Avatar
    Join Date
    Dec 2007
    Posts
    2,740
    Thanks given
    211
    Thanks received
    1,034
    Rep Power
    2455
    > - Greater than
    >= - Greater or equal to
    < - Less than
    <= - Less or equal to

    Example:

    Code:
    void function() {
       int rights = 2;
       if(somePlayer.returnRights() >= 2) {
            //Would allow any player with the rights greater or equal to two
       }
    Reply With Quote  
     

  3. #3  
    Member

    Join Date
    Aug 2009
    Age
    28
    Posts
    513
    Thanks given
    8
    Thanks received
    2
    Rep Power
    0
    Thanks aton
    Reply With Quote  
     

  4. #4  
    Member

    Join Date
    Aug 2009
    Age
    28
    Posts
    513
    Thanks given
    8
    Thanks received
    2
    Rep Power
    0
    Wait could anything just be equal too? So people above and people below couldnt use?

    For example if it was playerRights = 3

    Could only the person with player rights 3 use it?
    Reply With Quote  
     

  5. #5  
    Registered Member
    Core's Avatar
    Join Date
    Sep 2007
    Posts
    4,194
    Thanks given
    11
    Thanks received
    393
    Rep Power
    1985
    Code:
    if(playerRights == 3) {
    //do this
    }
    In if statements you must use 2 == signs but if your changing the value of the integer then you only use one like this
    Code:
    playerRights = 3;
    Reply With Quote  
     

  6. #6  
    Member

    Join Date
    Aug 2009
    Age
    28
    Posts
    513
    Thanks given
    8
    Thanks received
    2
    Rep Power
    0
    thanks
    Reply With Quote  
     

  7. #7  
    Registered Member
    killamess's Avatar
    Join Date
    Dec 2007
    Age
    33
    Posts
    1,508
    Thanks given
    51
    Thanks received
    284
    Rep Power
    1956
    also
    != not equal


    Reply With Quote  
     

  8. #8  
    Registered Member
    Its paris's Avatar
    Join Date
    Apr 2009
    Posts
    1,141
    Thanks given
    56
    Thanks received
    234
    Rep Power
    689
    If you want a String to be equal you must use the method aStringAtribute.equals("SomeThing"), which returns if the aStringAtribute is equals to "SomeThing".
    Or use aStringAtribute.equalsIgnoreCase("something") to check if it's the same (except for any capital letters).
    Reply With Quote  
     

  9. #9  
    Apple Computers
    Bridget7298's Avatar
    Join Date
    Aug 2007
    Age
    32
    Posts
    1,088
    Thanks given
    99
    Thanks received
    49
    Rep Power
    219
    Here's an example code:

    Code:
    if(playerRights >= 2)
    {
    sendMessage("I'm an Admin!");
    }
    else if(playerRights == 1)
    {
    sendMessage("I'm a Moderator!");
    }
    It's saying that if your rights are greater or equal to 2 then send the message:
    Code:
    sendMessage("I'm an Admin!");
    else if your player rights equal to 1 send the message:
    Code:
    sendMessage("I'm a Moderator!");
    >= Greater than or Equal to
    <= Less than or equal to
    > Greater than
    < Less than
    = Equals
    + Addition
    - Subtraction
    <> Greater or Less than
    ! = untrue

    In a code if you wanted to add points for how many times you were killed, you would do this:

    Declare this:
    Code:
    public int killed = 0;
    This is putting the int killed so we can call it.

    Then under your dieing method you would add this:
    Code:
    killed += 1;
    It doesn't mean HIGHER or EQUAL It's just saying add 1 int to the already equaled 0 int.

    Here's another code that you might want to know about:
    Code:
    if(playerRights != 2)
    {
    sendMessage("I'm neither moderator nor admin);
    }
    else if(playerRights != 1)
    {
    sendMessage("I'm neither moderator nor admin);
    }
    This:
    Code:
    !=
    Means if your player rights are not 2 send the message:
    Code:
    sendMessage("I'm neither moderator nor admin);
    Hope I helped
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

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