Page 2 of 2 FirstFirst 12
Results 21 to 23 of 23
  1. #21
    bl00dr3d is offline Member
    Join Date
    Apr 2009
    Posts
    17
    Rep Power
    0

    Default

    Hey man thanks for that it was real helpful. But for some reason my loop just isnt operating. Like using the following code I am only able to generate one letter..
    Heres the code -
    Java Code:
    private String generateSecretCode() {
            String secretCode = "";
    	int count = 0;
    	String letters = "ABCDEF";
    	while(count < 4) {
    	    String code = "";
    	    char randomLetter = letters.charAt((int)(Math.random() * 6));
                if(code.indexOf(randomLetter) == -1) {
    	        String newCode = code + randomLetter;
    	        count++;
    	        secretCode = newCode;
    	    }
    	}
    
    	return secretCode;
    }
    Last edited by bl00dr3d; 04-07-2009 at 10:05 AM.

  2. #22
    javabeginer is offline Member
    Join Date
    Apr 2009
    Posts
    8
    Rep Power
    0

    Default

    can some one tell me how to create a mastermind game using letters

  3. #23
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default

    javabeginer... it would be better if you started your own post about this topic.

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Generate a random code 4 letters long
    By bl00dr3d in forum New To Java
    Replies: 9
    Last Post: 04-06-2009, 05:32 AM
  2. Unique Filter on search results
    By selva in forum Lucene
    Replies: 0
    Last Post: 02-17-2009, 07:32 AM
  3. Need help with counting letters
    By mrdestroy in forum New To Java
    Replies: 15
    Last Post: 10-22-2008, 01:33 PM
  4. Letter with Letters
    By elgatoboricua in forum New To Java
    Replies: 7
    Last Post: 09-16-2008, 02:59 PM
  5. Unique element in an array
    By revathi17 in forum New To Java
    Replies: 2
    Last Post: 12-31-2007, 08:44 AM

Posting Permissions

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