Programming Assignment #77

Code


import java.util.Scanner;

public class adventure{

    public static void main(String[] args){
        
        Scanner k = new Scanner(System.in);
        System.out.println("Welcome to my adventure!! You are outside a cave, would you like to enter or leave?");
        k.next();
        System.out.println("Well, in we go then!");
        System.out.println("There are to different pathways, do you go left or right?");
        boolean end = false;
        
        while(end == false){
            
            String s = k.next();
            if(s.equals("right")){
                System.out.println("You walk for a bit and run into a dead end. Do you go back or stay?");
            }
            else if(s.equals("left")){
                System.out.println("You walk through the cave and come across a sleeping dragon. Do you go around or go back?");
            }
            else if(s.equals("stay")){
                System.out.println("You stare at the wall for a while and actually see a litte handle. So you pull it and a magical door opens.");
                System.out.println("Do you walk inside, or go back?");
            }
            else if(s.equals("back")){
                System.out.println("There are to different pathways, do you go left or right?");
            }
            else if(s.equals("around")){
                System.out.println("You sneak around the dragon and come into another room. You can't go back anymore.");
                System.out.println("There's a ladder up and a ladder down, which path do you take?");
            }
            else if(s.equals("up")){
                System.out.println("You start to climb the ladder but it squeaks and the dragon wakes up and roasts you. Bummer.");
                end = true;
            }
            else if(s.equals("down")){
                System.out.println("You climb down and discover the hidden treasure. Yay");
                end = true;
            }
            else if(s.equals("inside")){
                System.out.println("There's a portal in the room that teleports you to some island somewhere.");
                System.out.println("Maybe you should've been less adventurous...");
                end = true;
            }
            
        }
    
    }

}
  

Outputs

Assignment 15