Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Terminal Adventure 01 created by Kristen Luce */
- /* Please do not redistribute this code unless you are using it as a teaching tool or are referencing it */
- //Import scanner
- import java.util.Scanner;
- //begin the main (and possibly only) class
- public class TerminalAdventure01 {
- //set up scanner (imported from above)
- static Scanner input = new Scanner(System.in);
- //begin main (holds <almost> all functional code)
- public static void main(String[] args) {
- // Create the first couple of lines for when application is executed
- System.out.println("Hello friend, what is your name?");
- System.out.print("Please type your name: ");
- // Allow the user to input their name
- String name = input.nextLine();
- // Call the user by their selected name
- System.out.println("Ah, so your name is " + name + ", it's nice to meet you!");
- System.out.println("Anyhow, today is a very important day. Today is the day that you emark on a TERMINAL ADVENTURE!!");
- System.out.println("First, I need to know if you're human... are you a human? true or false. Please note that selecting false will exit the system.");
- System.out.print("Please type your answer: ");
- // Create a boolean scanner called humanAnswer that only accepts the words "true" or "false"
- boolean humanAnswer = input.nextBoolean();
- // An if statement that is run if the user types "true"
- if (humanAnswer == true)
- System.out.println("Good job, I believe you are very much human, " + name + "!");
- // An else if statement to fall back on in case the user says "false", exits program if run
- else if (humanAnswer == false)
- System.exit(0);
- System.out.print("Oh, I forgot to mention something. You cannot beat this TERMINAL ADVENTURE,");
- System.out.println(" you can only explore and find new things to aid you.");
- // Ask the user if they'd like to continue, warns user that the program will exit when 2 is typed.
- System.out.print("Will you continue? Type 1 for yes and 2 for no (typing 2 will force you to exit): ");
- // Set up questYes and questNo and link them to "1" and "2"
- int questYes;
- int questNo;
- questYes = 1;
- questNo = 2;
- // Have user input selection
- int questDecision = input.nextInt();
- // Very similar to the before if and else if statements
- if (questDecision == 1)
- System.out.println("Hey, " + name + ", I think you're ready.");
- else if (questDecision == 2)
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement