Thread: Constructor Problem

Results 1 to 3 of 3
  1. #1 Constructor Problem 
    Registered Member
    Join Date
    Dec 2011
    Posts
    27
    Thanks given
    1
    Thanks received
    1
    Rep Power
    11
    Code:
    src\server\model\players\Client.java:51: error: constructor PlayerKilling in cla
    ss PlayerKilling cannot be applied to given types;
            private PlayerKilling playerKilling = new PlayerKilling(this);
                                                  ^
      required: no arguments
      found: Client
      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.
    1 error
    Press any key to continue . . .

    dawat

    Code:
    package server.model.players;
    
    /**
    * @author Core
    * Handles adding and removing hosts to the players array list.
    */
    public class PlayerKilling {
    
    /**
    * Adds the host of the killed player.
    *@param client Player that saves the host.
    *@param host	Host address of the killed player.
    *@return True if the host is added to the players array.
    */
    
    public static boolean addHostToList(Client client, String host) {
    if(client != null) {
    return client.lastKilledPlayers.add(host);
    }
    return false;
    }
    
    /**
    * Checks if the host is already on the players array.
    * @param client Player that is adding the killed players host.
    * @param host Host address of the killed player.
    * @return True if the host is on the players array.
    */
    
    public static boolean hostOnList(Client client, String host) {
    if(client != null) {
    if(client.lastKilledPlayers.indexOf(host) >= KILL_WAIT_MAX) {
    removeHostFromList(client, host);
    return false;
    }
    return client.lastKilledPlayers.contains(host);
    }
    return false;
    }
    
    /**
    * Removes the host from the players array.
    * @param client Player that is removing the host.
    * @param host Host that is being removed.
    * @return True if host is successfully removed.
    */
    
    public static boolean removeHostFromList(Client client, String host) {
    if(client != null) {
    return client.lastKilledPlayers.remove(host);
    }
    return false;
    }
    
    /*
    * Amount of kills you have to wait before the host is deleted.
    */
    
    public static final int KILL_WAIT_MAX = 3;
    
    }
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Apr 2012
    Age
    27
    Posts
    2,936
    Thanks given
    1,126
    Thanks received
    1,081
    Rep Power
    0
    Ok, learn conventions please, that just looks god awful.

    For the Fix, just do this below public class PlayerKilling:

    Code:
    private final Client c;
    
    public PlayerKilling(final Client Client) {
    	c = Client;
    }
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Dec 2011
    Posts
    27
    Thanks given
    1
    Thanks received
    1
    Rep Power
    11
    I got that class from a Archive, so it was not in a BBC code format. compiled fine, let me see if it worked.
    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. constructor ClanChatHandler() ???
    By Streams2lakes in forum Help
    Replies: 1
    Last Post: 06-20-2012, 02:17 AM
  2. Vines constructor problem
    By miniclip152 in forum Help
    Replies: 0
    Last Post: 02-12-2012, 01:09 AM
  3. Replies: 5
    Last Post: 01-25-2012, 12:05 AM
  4. Constructor
    By Byakuya Kuchiki in forum Help
    Replies: 0
    Last Post: 10-20-2009, 12:56 AM
  5. Constructor Error..
    By Elid in forum Help
    Replies: 4
    Last Post: 01-18-2009, 05:29 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
  •