Skip to main content
gamedev.net
🔒 Locked

java prob

Started by shaun23 Mar 22, 2005 at 12:50 AM 0 replies 400+ views
Original Post
shaun23
shaun23
hey guys i'm new to programming, i need help with a JAVA game i'm desiging. i need to create a test game where 2 clients can ONLY connect!!!!! my problem is that i need a method that checks that each client has a unique player name!!!! the method should check the players names, and display an error if the same name has been taken!!. i have a exisitng class named Users, this class creates new players, i would like to implement this method inside this class!!. PLEASE HELP ASAP
NickyP101
NickyP101
Haha ok you prob wont understand this, but good luck.

This is just an example.

//Global VariablesSet users;public void init(){   users = new HashSet();}public void checkName(String name){   if(users.contains(playerName)){       System.out.println("Sorry, " + name + " is already in use");       //Send message to client.   }   else{         users.add(name);   }}}


Need nething else?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.