Untitled

 avatar
unknown
plain_text
a year ago
2.0 kB
0
Indexable
import java.util.Scanner;

public class TextAdventureGame {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        // Introduction
        System.out.println("Welcome to the Text Adventure Game!");
        System.out.println("You find yourself in a mysterious land.");
        System.out.println("Your choices will determine your fate.");
        
        // Start the game
        startGame(scanner);
    }

    public static void startGame(Scanner scanner) {
        System.out.println("\nYou stand at a crossroad.");
        System.out.println("What do you do?");
        System.out.println("1. Go left.");
        System.out.println("2. Go right.");
        System.out.println("3. Quit the game.");

        int choice = scanner.nextInt();

        switch (choice) {
            case 1:
                // Left path - Create your own story here
                System.out.println("\nYou chose to go left.");
                System.out.println("This path leads you to a dark cave...");
                // Continue the story based on the player's choice
                break;
            case 2:
                // Right path - Create your own story here
                System.out.println("\nYou chose to go right.");
                System.out.println("This path leads you to a magical forest...");
                // Continue the story based on the player's choice
                break;
            case 3:
                // Quit the game
                System.out.println("\nThanks for playing! Goodbye!");
                System.exit(0);
                break;
            default:
                System.out.println("\nInvalid choice. Please select 1, 2, or 3.");
                startGame(scanner);
                break;
        }

        // You can continue the game by calling other methods or creating a game loop.
        // Remember to use loops and methods for a more complex and engaging story.
    }
}