jeudi 24 novembre 2016

Objects in a switch statment

How can I use objects in a switch statement? I am obliged to use objects in my code. I need to know how to compare objects, by using and If statement or a switch statement.

    userInput=userLnr.readLine();
        if (userInput !=null) {
            clerk1.username=userInput;
            userInput=userLnr.readLine();
            clerk2.username=userInput;
            userInput=userLnr.readLine();
            clerk3.username=userInput;
            userInput=userLnr.readLine();
            clerk4.username=userInput;
            userInput=userLnr.readLine();
            clerk1.password=userInput;
            userInput=userLnr.readLine();
            clerk2.password=userInput;
            userInput=userLnr.readLine();
            clerk3.password=userInput;
            userInput=userLnr.readLine();
            clerk4.password=userInput;
        }

    System.out.println("Enter username: ");
    String inputUsername=Keyboard.readString();
    System.out.println("Enter password: ");
    String inputPassword=Keyboard.readString();

    switch(inputUsername){
        case clerk1.username:
    }

Aucun commentaire:

Enregistrer un commentaire