Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.util.Scanner;
- public class TheAdventure {
- public static String pClass;
- public static int Level = 1;
- public static double Health = 100.0;
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Random randomGenerator = new Random();
- Scanner playerInput = new Scanner(System.in);
- System.out.println("Welcome, welcome, young and old, to the Mines of Mystery.");
- System.out.println("You may just strike it rich, or you will find yourself stuck here forever.");
- // Telling the player what his or her name is, and that they start out as level 1.
- boolean Alive = true;
- String Name = "Professor Oak";
- System.out.println("Choose a class:\n1 - Soldier\n2 - Athlete\n3 - Genius");
- int playerClass = playerInput.nextInt();
- if((playerClass == 1)|| (playerClass == 2) ||(playerClass == 3)){
- System.out.println("Nice!");
- }
- else{
- System.out.println("Oops! You did not follow directions! Please restart the game!");
- playerInput.close();
- }
- if(playerClass == 1){
- pClass = "Soldier";
- }
- else if(playerClass == 2){
- pClass = "Athlete";
- }
- else{
- pClass = "Genius";
- }
- System.out.println("What is your name, fine " + pClass + "?");
- playerInput.nextLine();
- Name = playerInput.nextLine();
- System.out.println("You are " + Name + ", a level " + Level + " " + pClass +"!");
- System.out.println("Would you like to enter the mine? (Y/N)");
- String Enter = playerInput.nextLine();
- if(!Enter.equalsIgnoreCase("Y")&&!Enter.equalsIgnoreCase("Yes")){
- System.out.println("You suddenly remember why you wanted to explore the mine in the first place." +
- "\nSuddenly, a large horde of zombies peaks over the mountain. You are spotted." +
- "\nWith nowhere to go, you close your eyes as your flesh is eaten. You are dead.");
- System.exit(0);
- }
- //Entering the mine
- System.out.println("You have entered the mine!");
- Level = Level + 1;
- System.out.println("Congratulations on levelling up! You are now a Level " + Level + " " + pClass + "!");
- //A rock hits the player
- double rockDamage = 10.0;
- Health -= rockDamage;
- System.out.println("Oof! A rock just hit you! You have learned how bad rocks are!");
- System.out.println("You took " + rockDamage + " damage! Now your health is " + Health + ".");
- //Is the player dead yet?
- if( Health <= 0 ){
- System.out.println("Oh noooooooo, "
- + Name + " died They were level "
- + Level);
- }
- //Fountain of Youth?
- System.out.println("You find a fountain. Is this the Fountain of Youth you've been looking for?");
- System.out.println("If you would like to drink, please type 'drink'! If not, write 'ignore'.");
- String playerAnswer = "?";
- playerAnswer = playerInput.nextLine();
- if(playerAnswer.equalsIgnoreCase("drink")){
- Health--;
- Level++;
- System.out.println("That was some yucky water. Definitely not what you were looking for. At least you've levelled up!");
- System.out.println("Congratulations on levelling up! You are now a Level " + Level + " " + pClass + "!");
- System.out.println("You took 1 damage point. Your health is now " + Health + ".");
- }
- else if(playerAnswer.equalsIgnoreCase("ignore")){
- Health = Health + 5;
- Level = Level + 2;
- System.out.println("Smart choice! That water would have made you VERY sick!"
- + "\nInstead you decided to eat an apple, filling you with some precious vitamins!"
- + "\nCongratulations on levelling up! You are now a Level " + Level + " " + pClass + "!"
- + "\nYour apple gave you 5 health. Your health is now " + Health + ".");
- }
- else{
- System.out.println("You are horrible at following directions! For your stupidity, you will lose 20 health.");
- Health = Health - 20;
- System.out.println("Your health is now " + Health + ".");
- }
- //Is the player dead yet?
- if( Health <= 0 ){
- System.out.println("Oh noooooooo, "
- + Name + " died They were level "
- + Level);
- }
- //Math Teacher Appears!
- System.out.println("You see a figure mumbling to itself."
- +"\nDo you go to discover who it is? (Y/N)");
- String Investigation;
- Investigation = playerInput.nextLine();
- //Addition Question
- if(Investigation.equalsIgnoreCase("Y") || Investigation.equalsIgnoreCase("Yes")){
- System.out.println("Upon closer investigation, you discover the person is your math teacher!"
- +"\nYour teacher decides to make a deal with you. Answer math questions correctly, you get level-ups."
- +"\nHowever, if you get the question wrong, you get Fs, and you will become sicker!");
- int mathFirst = randomGenerator.nextInt(51);
- int mathSecond = randomGenerator.nextInt(51);
- int mathThird = mathFirst + mathSecond;
- System.out.println("First question: What is " + mathFirst + " + " + mathSecond + "? \nYOU MUST ONLY WRITE DIGITS OR THE GAME WILL CRASH");
- int firstAnswer;
- firstAnswer = playerInput.nextInt();
- if(firstAnswer == mathThird){
- questionCorrect();
- }
- //But What if the player #GotItWrong?
- else{
- questionIncorrect();
- }
- //Multiplication Question
- int mathFourth = randomGenerator.nextInt(21);
- int mathFifth = randomGenerator.nextInt(21);
- int mathSixth = mathFourth * mathFifth;
- System.out.println("Second question: What is " + mathFourth + " * " + mathFifth + "?\nYOU MUST ONLY WRITE DIGITS OR THE GAME WILL CRASH");
- int secondAnswer;
- secondAnswer = playerInput.nextInt();
- if(secondAnswer == mathSixth){
- questionCorrect();
- }
- //But What if the player #GotItWrong?
- else{
- questionIncorrect();
- }
- //Subtraction Question
- int mathSeventh = randomGenerator.nextInt(51) + 50;
- int mathEighth = randomGenerator.nextInt(51);
- int mathNinth = mathSeventh - mathEighth;
- System.out.println("Third question: What is " + mathSeventh + " - " + mathEighth + "?\nYOU MUST ONLY WRITE DIGITS OR THE GAME WILL CRASH");
- int thirdAnswer;
- thirdAnswer = playerInput.nextInt();
- if(thirdAnswer == mathNinth){
- questionCorrect();
- }
- //But What if the player #GotItWrong?
- else{
- questionIncorrect();
- }
- //Division Question
- int mathTenth = randomGenerator.nextInt(10) + 1;
- int mathEleventh = randomGenerator.nextInt(21) * mathTenth;
- int mathTwelfth = mathEleventh / mathTenth;
- System.out.println("Fourth question: What is " + mathEleventh + " / " + mathTenth + "?\nYOU MUST ONLY WRITE DIGITS OR THE GAME WILL CRASH");
- int fourthAnswer;
- fourthAnswer = playerInput.nextInt();
- if(fourthAnswer == mathTwelfth){
- questionCorrect();
- }
- //But What if the player #GotItWrong?
- else{
- questionIncorrect();
- }
- playerInput.nextLine();
- }
- //Making Your Third Choice
- System.out.println("You realize that you are now in some sort of large cavern."
- +"\nIf you go left, you will probably die. If you go right, you might get your first riches.");
- System.out.println("You need to make a choice. Will you go left or right?");
- System.out.println("So, will you go left or right? Please type your answer below.");
- String playerAnswer2 = playerInput.nextLine();
- //If the player makes the smart choice
- if(playerAnswer2.equalsIgnoreCase("right")){
- System.out.println("You found a gold nugget! Great job!");
- Level = Level + 1;
- System.out.println("Congratulations on levelling up! You are now a Level " + Level + " " + pClass + "!");
- }
- //If the player is very stupid and doesn't listen
- else if(playerAnswer2.equalsIgnoreCase("left")){
- System.out.println("The path gets very dark. Another cunning rock ambushes you.");
- rockDamage = randomGenerator.nextInt(40);
- Health -= rockDamage;
- System.out.println("You took " + rockDamage
- + " damage. You have " + Health
- + " health remaining.");
- }
- else{
- System.out.println("You are horrible at following directions! For your stupidity, you will lose 20 health.");
- Health = Health - 20;
- System.out.println("Your health is now " + Health + ".");
- }
- //Is the player dead yet?
- if( Health <= 0 ){
- System.out.println("Oh noooooooo, "
- + Name + " died They were level "
- + Level);
- }
- //Endgame
- else{
- System.out.println(Name +" survived the Mines of Mystery! You made it to level "+ Level + "." + "\nFinal health: " + Health);
- }
- playerInput.close();
- }
- //Add some more choices here later!
- //Remember to fix non-math teacher bug
- public static void questionCorrect(){
- System.out.println("Nice job! You got that question right and you get a level-up!");
- Level = Level + 1;
- System.out.println("Congratulations on levelling up! You are now a Level " + Level + " " + pClass + "!");
- }
- public static void questionIncorrect(){
- System.out.println("FAIL! You got that math question wrong! You are beginning to feel a bit sick.");
- Health = Health - 10;
- System.out.println("Your health is now " + Health + ".");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement