mardi 30 juin 2020

Check in if is switch case choosen

How can i check if case (for example 3 ) was choosen to make continuation of story? I wrote this in java and I would go full detail with story but i dont know how could i .I thought I could nest cases inside each other but if I can choose options(scanner.nextInt();) also add in them.I thought if statement would work better but i dont know how can i check it .I must add that didnt found any answers to this problem before posting.Thanks for reviewing and have a good day

             int choice_1 = scanner.nextInt();
        switch(choice_1)
        {
            case 1:
                System.out.println("Guard: Its a honor to meet u sir.Its a pleasure to let You through \nBut do u have coin pass?");
                if(pass==1){
                    ending();
                }
                else{"You should get coin pass first. I am sure that wont be a problem for Prince *laughs*"}
                break;
            case 2:
                System.out.println("*Guard immediately avoided attack and attack u harder that u excepted");
                playerHp = playerHp -30;
                playerArmorHp = playerArmorHp - 50;
                break;

            case 3:
                System.out.println("Guard : Goodbye Sir");
                plan();
                break;
            default:
                System.out.println("Guard is impatient of your not telling anything.Choose option before making him mad.\n"+line);
                break;
        }
        if(switch ( case:3)){
            System.out.println("Do u have coin pass?");
            int pass = scanner.nextInt();
        }

Aucun commentaire:

Enregistrer un commentaire