Thread: [PI] I just need a tad bit of help

Results 1 to 9 of 9
  1. #1 [pi] please help me!! 
    Registered Member
    Join Date
    Aug 2011
    Age
    26
    Posts
    330
    Thanks given
    7
    Thanks received
    6
    Rep Power
    11
    I followed the "Percentage Base Drop System for PI" tutorial and I have wound up with these three errors:
    Code:
    source\server\model\npcs\NPCHandler.java:3142: error: cannot find symbol
                                                    Server.itemHandler.createGroundI
    tem(c, dropTable.get(0)[1], npcs[npcIndex].absX, npcs[npcIndex].absY, Misc.range
    (Config.itemDrops[dropTable.get(0)[0]][2], Config.itemDrops[dropTable.get(0)[0]]
    [3]), npcs[npcIndex].killerId);
    
                                                                              ^
      symbol:   method range(int,int)
      location: class Misc
    source\server\model\npcs\NPCHandler.java:3174: error: cannot find symbol
                                    Server.itemHandler.createGroundItem(c, dropTable
    .get(0)[1], npcs[npcIndex].absX, npcs[npcIndex].absY, Misc.range(Config.itemDrop
    s[dropTable.get(0)[0]][2], Config.itemDrops[dropTable.get(0)[0]][3]), npcs[npcIn
    dex].killerId);
    
                                                              ^
      symbol:   method range(int,int)
      location: class Misc
    source\server\model\npcs\NPCHandler.java:3178: error: cannot find symbol
                                    Server.itemHandler.createGroundItem(c, dropTable
    .get(0)[1], npcs[npcIndex].absX, npcs[npcIndex].absY, Misc.range(Config.itemDrop
    s[dropTable.get(0)[0]][2], Config.itemDrops[dropTable.get(0)[0]][3]), npcs[npcIn
    dex].killerId);
    
                                                              ^
      symbol:   method range(int,int)
      location: class Misc
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    3 errors
    Press any key to continue . . .
    If I replace range with: random I get the following, similar error:
    Code:
    source\server\model\npcs\NPCHandler.java:3142: error: method random in class Mis
    c cannot be applied to given types;
                                                    Server.itemHandler.createGroundI
    tem(c, dropTable.get(0)[1], npcs[npcIndex].absX, npcs[npcIndex].absY, Misc.rando
    m(Config.itemDrops[dropTable.get(0)[0]][2], Config.itemDrops[dropTable.get(0)[0]
    ][3]), npcs[npcIndex].killerId);
    
                                                                              ^
      required: int
      found: int,int
      reason: actual and formal argument lists differ in length
    source\server\model\npcs\NPCHandler.java:3174: error: method random in class Mis
    c cannot be applied to given types;
                                    Server.itemHandler.createGroundItem(c, dropTable
    .get(0)[1], npcs[npcIndex].absX, npcs[npcIndex].absY, Misc.random(Config.itemDro
    ps[dropTable.get(0)[0]][2], Config.itemDrops[dropTable.get(0)[0]][3]), npcs[npcI
    ndex].killerId);
    
                                                              ^
      required: int
      found: int,int
      reason: actual and formal argument lists differ in length
    source\server\model\npcs\NPCHandler.java:3178: error: method random in class Mis
    c cannot be applied to given types;
                                    Server.itemHandler.createGroundItem(c, dropTable
    .get(0)[1], npcs[npcIndex].absX, npcs[npcIndex].absY, Misc.random(Config.itemDro
    ps[dropTable.get(0)[0]][2], Config.itemDrops[dropTable.get(0)[0]][3]), npcs[npcI
    ndex].killerId);
    
                                                              ^
      required: int
      found: int,int
      reason: actual and formal argument lists differ in length
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    3 errors
    Press any key to continue . . .
    I'm not sure what to do. Thanks in advance for any help.
    Reply With Quote  
     

  2. #2  
    0x2be|~0x2be
    akamichael's Avatar
    Join Date
    Jan 2012
    Age
    28
    Posts
    73
    Thanks given
    1
    Thanks received
    8
    Rep Power
    44
    The method "range" cannot be found in the Misc class. The "random" method in the Misc class cannot have 2 integer values passed into it, only one. Either you overload the "random" method inside of Misc to accept 2 integer values and have it determine the range, or create your own range method for Misc.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Aug 2011
    Age
    26
    Posts
    330
    Thanks given
    7
    Thanks received
    6
    Rep Power
    11
    Quote Originally Posted by akamichael View Post
    The method "range" cannot be found in the Misc class. The "random" method in the Misc class cannot have 2 integer values passed into it, only one. Either you overload the "random" method inside of Misc to accept 2 integer values and have it determine the range, or create your own range method for Misc.
    And how would I overload it to accept 2 integer values?
    Reply With Quote  
     

  4. #4  
    Owner of Dawntained

    Mgt Madness's Avatar
    Join Date
    Oct 2011
    Age
    28
    Posts
    3,380
    Thanks given
    1,429
    Thanks received
    958
    Rep Power
    2168
    Quote Originally Posted by flamehair9 View Post
    And how would I overload it to accept 2 integer values?
    To fix le error
    Attached image
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Aug 2011
    Age
    26
    Posts
    330
    Thanks given
    7
    Thanks received
    6
    Rep Power
    11
    Quote Originally Posted by Mgt Madness View Post
    To fix le error
    Well obviously doing that would fix the error haha , I want to know how to do that.
    Reply With Quote  
     

  6. #6  
    0x2be|~0x2be
    akamichael's Avatar
    Join Date
    Jan 2012
    Age
    28
    Posts
    73
    Thanks given
    1
    Thanks received
    8
    Rep Power
    44
    In the Misc class overload the random method:

    Code:
    /**
    *random method
    *@param number1
    *@param number2
    *@return random number
    */
    public static int random(int number1, int number2)
    {
         return random(number1) + random(number2); //returns the sum of two random numbers
    } //end of random method
    That is an example of overloading the random method inside of the Misc class. If you wanted a method to find the range of 2 integers you would have different code within the methods body.
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Nov 2013
    Posts
    126
    Thanks given
    5
    Thanks received
    21
    Rep Power
    42
    >.< Add my skype: its_jay.s
    if you still need help.
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Aug 2011
    Age
    26
    Posts
    330
    Thanks given
    7
    Thanks received
    6
    Rep Power
    11
    Quote Originally Posted by akamichael View Post
    In the Misc class overload the random method:

    Code:
    /**
    *random method
    *@param number1
    *@param number2
    *@return random number
    */
    public static int random(int number1, int number2)
    {
         return random(number1) + random(number2); //returns the sum of two random numbers
    } //end of random method
    That is an example of overloading the random method inside of the Misc class. If you wanted a method to find the range of 2 integers you would have different code within the methods body.
    Here's my random method. I've messed with it and I cant make it work with the above. Help still required. Thanks
    Code:
    	public static int random(int range) {
    		return (int)(java.lang.Math.random() * (range+1));
    	}
    Reply With Quote  
     

  9. #9  
    0x2be|~0x2be
    akamichael's Avatar
    Join Date
    Jan 2012
    Age
    28
    Posts
    73
    Thanks given
    1
    Thanks received
    8
    Rep Power
    44
    Quote Originally Posted by flamehair9 View Post
    Here's my random method. I've messed with it and I cant make it work with the above. Help still required. Thanks
    Code:
    	public static int random(int range) {
    		return (int)(java.lang.Math.random() * (range+1));
    	}
    Your error is because you're trying to pass 2 arguments into a 1 argument method. Adding a random method with 2 arguments would fix the problem.
    Example:
    Code:
            import java.util.Random;
    
    	public static int random(int number1, int number2)
            {
                    Random random = new Random();
    		return random.nextInt(number1 + 1) + random.nextInt(number2 + 1));
    	}
    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

Similar Threads

  1. Replies: 2
    Last Post: 05-28-2011, 05:56 AM
  2. need a little bit of help!
    By taffzimo in forum Help
    Replies: 0
    Last Post: 12-13-2010, 06:46 PM
  3. Replies: 2
    Last Post: 10-30-2010, 08:56 PM
  4. [req] I need a little bit of help
    By Kronix in forum Tutorials
    Replies: 9
    Last Post: 04-22-2008, 08:00 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •