Thread: Is this done right?

Results 1 to 3 of 3
  1. #1 Is this done right? 
    RiotScape FTW
    Guest
    IDK if this is properly done, it does work - but done correctly?

    Code:
    	public static int[] VOID_SET = {8839, 8840, 8842};
    	public static int RANGER_HELM = 11664;
    	public static int MELEE_HELM = 11665;
    	public static int MAGE_HELM = 11663;
    	
    	/**
    	 * Does the player have a full void set?
    	 * @param player person that is checked
    	 * @param set identifies the set number (1 for melee, 2 for range, 3 for mage)
    	 * @return true or false
    	 * @author Canownueasy
    	 * @author Harry
    	 */
    	public static boolean hasVoidSet(Player player, final int set) {
    		int HELM = 0;
    		if(player.getEquipment().contains(VOID_SET.length)) { //Does the player have the set?
    			switch(set) {
    				case 1: //Melee
    					HELM = MELEE_HELM;
    					break;
    				case 2: //Range
    					HELM = RANGER_HELM;
    					break;
    				case 3: //Mage
    					HELM = MAGE_HELM;
    					break;
    			}
    			if(player.getEquipment().contains(HELM)) { //If they have the helm, they have full void
    				return true;
    			} else {
    				return false;
    			}
    		} else {
    			return false;
    		}
    	}
    Reply With Quote   Received Infraction 
     

  2. #2  
    Registered Member

    Join Date
    Feb 2009
    Age
    27
    Posts
    2,861
    Thanks given
    127
    Thanks received
    226
    Rep Power
    700
    That only checks if they have the helmet, so no.
    Reply With Quote  
     

  3. #3  
    Member Is this done right? Market Banned


    Luke132's Avatar
    Join Date
    Dec 2007
    Age
    35
    Posts
    12,574
    Thanks given
    199
    Thanks received
    7,106
    Rep Power
    5000
    variables in all capitals are for constants (variables that dont change), therefore helm shouldn't be in all capitals, and constants should also be declared final, and reading that i just realised who you are so i'll ban u once i've typed this up.

    you could get rid of the ugle if/else statement and just have

    return (player.getEquipment().contains(HELM));

    Attached imageAttached image
    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
  •