Adventure game

Report a typo

Here's an example of a switch statement as part of a text-based adventure game. In this example, the switch statement is used to handle different player choices within the game. The program prints the part of the story and, based on his choice, outputs the continuation of the story. Decide which choice refers to which output and fill in the blanks in the switch statement.

Fill in the gaps with the relevant elements
System.out.println("Welcome to the Adventure Game!");
System.out.println("Choose your path: 1) Forest, 2) Cave, 3) Castle");

int choice = scanner.nextInt();

switch (choice) {
    case 1:
        System.out.println();
        ...
        break;
    case 2:
        System.out.println();
        ...
        break;
    case 3:
        System.out.println();
        ...
        break;
    default:
        System.out.println();
        break;
}
"You approach a majestic castle. Guards are at the entrance.""You enter a dark cave. It is pitch black inside.""You enter the mysterious forest.""Invalid choice. The adventure ends."
___

Create a free account to access the full topic