Results 1 to 2 of 2
  1. #1
    quickfingers is offline Member
    Join Date
    Dec 2007
    Posts
    21
    Rep Power
    0

    Default Password System help

    Ok I am working on a game which I would like to add a password System too .

    Here is what my screen looks like

    U= Up Button
    D= Down Button
    #= number
    // Just a guide for the picture

    U U U U

    # # # #

    D D D D

    Now this is what I want it to do

    I want to make it so when you click the first Up arrow only the first number goes up or if you click the down arrow only the first # goes down

    and the same thing for the other 3 Images I made

    This is what I have done

    I have it so the buttons change the correct int
    Add MouseClicked Since I used KeyPressed

    This is what I need

    All I need now is to check if the password is correct when they place in the password



    This was what I was trying

    //init
    password[0]="1024";

    //in run so it always checking
    if(password[0]==""+num1+num2+num3+num4)

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    7

    Default A place to start.

    Java Code:
    // Ok, very simple - for a game. No supercrunching or anything.
    // I suppose we could start like this:
    // A little complicated for a starter effort.
    class supercruncher 
    {
        int[][] pwStore = new int[3][4];
        supercruncher()
        {
            // conceptual - to be coded .....
            // We can unroll the loop for simplicity.
            for(pwStore.length) = passwordAsInt;
        }
        // ..... other code here
        if(checkPassword(int suppliedValue))
        {
            int loopControl = pwStore.length;
            do
            {
                // this next line is not correct
                if(pwStore.[--loopControl] == suppliedValue)
                {
                    return true;
                }
            }
            while(loopControl > 0);
            return false;
        }
    }
    // This is ineffective - always checking is something one
    // would place in the run loop in a game
    if(password[0]==""+num1+num2+num3+num4)

    Also, for four numbers - the way I have the array is incorrect. Several things in the code are indeterminate until you provide us some feedback....
    Last edited by Nicholas Jordan; 06-23-2008 at 06:21 PM. Reason: note errors in code

Similar Threads

  1. Asking for password from a Servlet
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-27-2008, 08:05 PM
  2. add password to folder
    By ismailsaleh in forum AWT / Swing
    Replies: 1
    Last Post: 01-08-2008, 05:46 AM
  3. Problem with a password
    By saytri in forum New To Java
    Replies: 2
    Last Post: 12-27-2007, 11:06 AM
  4. Help, created a username and password box
    By cachi in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 04:21 AM
  5. Help with password matches
    By Albert in forum AWT / Swing
    Replies: 1
    Last Post: 07-10-2007, 04:17 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
  •