I fix

 avatar
unknown
java
2 years ago
2.8 kB
3
Indexable
package com.mycompany.planecrashcyoa;

/*
1) if(condition){
    if(condition2){
        //this block only runs if "condition" AND "condition2" == true
    }
    print("hi"); //will run if "condition" == true
}

IS NOT THE SAME AS

if(condition){
    //will run if "condition" is true
}
if(condition2){
    //will run of "condition2" is true
}
 */


/*

    if(condition){
        //if "condition" == true, run
    }else if("condition2){
        //if condition == false AND condition2 == true, run
    }else{
        if condition == false AND condition2 == false, run this
    }
 */


import java.util.Scanner;

/**
 *
 * @author jasmanngrewal
 */
public class test {



    public static void main(String[] args) {
        System.out.println("Oh no! Your plane has crashed in the ocean! It is time to make smart descions, play the game and try to survive. Good luck!");

        Scanner keyInput= new Scanner(System.in);

        String response1;
        String response2;
        String response3;
        String response4;

        System.out.println ("Does your phone work (yes/no)?");
        response1 = keyInput.nextLine();

        if (response1.equals("yes")) {
            System.out.println("Would you like to call your family or yell for help (family/yell)?");
            response2 = keyInput.nextLine();
            if (response2.equals("family")) {
                System.out.println("You family did not pick up, after waiting for them to call back you got eaten by a whale!");
            }
            else if (response2.equals("yell")) {
                System.out.println("Yay! A helicopter heard your screams and saved you! Congratulations on surviving!");
            }
        }
        if (response1.equals("no")) {
            System.out.println("Are there any other survivors with you (yes/no)?");
            response3 = keyInput.nextLine();
            if (response3.equals("no"))
            {
                System.out.println("Oh no, no one else survived! You get tired and drowned in the ocean.");
            }

            if (response3.equals("yes"))
            {
                System.out.println ("You see survivors on the left and right. Who would you like to swim towards (left/right)?");
                response4 = keyInput.nextLine();
                if (response4.equals("left"))
                {
                    System.out.println ("You have swam to the left, but on your way there you get eaten by a shark");
                }else if (response4.equals("right"))
                {
                    System.out.println ("You found another survivior who can help. Congratulations on surviving! ");
                }
            }
        }
    }
}