Just need a little help with some coding

Discussion in 'Programming' started by 16keane, Dec 17, 2006.

  1. #1
    Hi all,

    I was hoping i could just get a little bit of help just putting some coding to together using JCLcreator and doing standard. I am trying to get the following thing on my screen where you can enter username and password, which after succesful takes you to the main menu.

    http://i10.photobucket.com/albums/a132/fazmufc/usernameandpassword.jpg
    http://i10.photobucket.com/albums/a132/fazmufc/mainmenupassword.jpg

    Here is the code i got below, i dont know if anyone knows whats wrong as i been stuck. I am total novice, so to get this far for me is a achivement :D just been using the book over the weekend but was hoping someone could help me out


    import java.util.Scanner;
    
    public class InterfaceControl
    {
    	public static void main (String[] args)
    	{
    		// this is the starting point for the whole thing
    		InterfaceControl ic = new InterfaceControl()
    		boolean loggedIn = false;
    
    		loggedIn = ic.login();
    
    		while (!loggedIn)
    		{
    			// let them keep trying to log in
    			loggedIn = ic.login();
    		}
    
    		// they reached this point so they must be logged in
    		ic.showMenu();
    	}
    
    	public void showMenu()
    	{
    			System.out.println("======Welcome to the main menu====\n" );
    			System.out.println("Type 0: Exit.\n" );
    			System.out.println("Type 1: View Ski Run Length\n" );
    			System.out.println("Type 2: View Limits of Skiers \n" );
    
    			
    		Scanner st = new Scanner (System.in);
    		System.out.println ("\n");
    		System.out.println ("\t" + "Enter choice of option." );
    		
    			choice=st.nextInt();
    			int choice = st.nextInt();
    
    			if (choice == 1)
    			{
    				otherClass.viewrunlengths();
    			}
    			else if (choice == 2)
    			{
    				otherClass.viewlimitsofskiers();
    			}
    			else if (choice == 0)
    			{
    				System.exit();
    			}
    		}
    	}
    
    	public boolean login()
    	{
    			public static boolean loginSuccessfull()
    	{
    		
    		Scanner st = new Scanner (System.in);
    		System.out.println ("\n");
    		System.out.println ("\t" + "Enter Username." );
    		System.out.print("\t");		
    		String userName = st.nextLine();
    		
    		System.out.println ("\n");
    		System.out.println ("\t" + "Enter Password ." );
    		System.out.print("\n");		
    		String password = st.nextLine();
    		
    		if( Security.checkLogin(userName, password) == true )
    		{
    			return true;
    		}
    		else
    		{
    			return false;
    		}
    	}
    	}
    }
    Code (markup):

     
    16keane, Dec 17, 2006 IP
  2. Arkserver

    Arkserver Banned

    Messages:
    2,533
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if your logged in try "showMenu()" it should work.
     
    Arkserver, Dec 18, 2006 IP