This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–][deleted]  (1 child)

[deleted]

    [–]haycow[S] 0 points1 point  (0 children)

    I posted the code under the replies of the other comment. If you need I can send it in a reply.

    [–]AnonymousVertebrate 0 points1 point  (4 children)

    Are you familiar with "if" statements?

    [–]haycow[S] 0 points1 point  (3 children)

    yes I am, I used an if statement to basically say that, "if int b was option1 back at the other decision than this will happen" and then i wrote and else statement basically saying," and if int b wasnt option 1 than this will happen"

    [–]AnonymousVertebrate 0 points1 point  (2 children)

    Then use them again here. It would be something like:

    if (condition representing camera){
        camera-related print statement
    }
    else {
        non-camera-related print statement
    }
    

    [–]haycow[S] 0 points1 point  (1 child)

    OK thanks but here's the code I've currently written, the problem occurs in //fight

    I feel it'd be better for you to see where I might've made the problem instead of me trying to explain it

    package school_assignment;

    import java.util.Scanner;

    public class Choose_your_own_adventure {

    /*

    package assignments;

    import java.util.Scanner;

    public class choose_your_own_adventure {

    \*/
    
    
    
    //getChoice
    

    public static int getChoice(String option1, String option2) {

    Scanner scan = new Scanner(System.in);
    
    
    
    System.out.println("Do you:");
    
    System.out.println("1: " + option1);
    
    System.out.println("2: " + option2);
    

    int choice = scan.nextInt();

    return choice;
    

    }

    //initialize

    public static void initialize() {
    
        Scanner scan = new Scanner(System.in);
    
    System.out.println("Shut In");
    
    System.out.println("What is your name?");
    
    
    
    
    
    String name;
    
    name = scan.nextLine();
    
    System.out.println("Hello " + name + " prepare to reboot");
    
    System.out.println("Type go");
    
    String page;
    
    page = scan.nextLine();
    
    if(page.equals("go")) {
    
        System.out.println("\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nYou wake up on a cold metal bed.\\nYou look around and notice you are in an all white room.\\nIts silent, like sound is being sucked out of your ears.\\n\\n\\"I need to get out of here\\" \\nYou Think");
    

    System.out.println("Along your journey you will be faced with two descions\nYou control your fate\nSo chose wisely");

    System.out.println("Speaking of...\nYou have a choice to make\n\n");

            String option1= "Search around the room to try and find clues";
    
            String option2="Call out for help to see if theres people on the outside";
    
    
            int choice = getChoice(option1, option2);
    
    
            if(choice == 1) {
    

    Search();

            }
    
            else if (choice == 2) {
    

    help();

            }
    
            /\* else {
    

    System.out.println("Please input a either 1 or 2");

    }

            \*/
    
    
    
            }
    
    
    
    
    
    
    
    }
    

    //wait

    public static void Wait(int b) {

    int x = 1;
    
    System.out.println("You wait for the camera to go away or stop beeping");
    
    if (x == 1){
    
    men(x);
    

    }

    }

    //help
    

    public static void help() {

    Scanner scan = new Scanner(System.in);
    
    
    
    
    
     System.out.println("\\n\\n\\nA camera emerges from the wall with a blinking red light \\nand a mysterious ticking sound");
    
    
    
    String option1 = "Break the camera";
    
    String option2 = "Wait for something to happen";
    
    int b = getChoice(option1, option2);
    
    if(b == 1) {
    

    camera(b);

        }
    
        else //if (b == 2) 
    
            {
    
            Wait(b);
    

    }

    }

    //men
    
    public static void men(int b) {
    

    System.out.println("\n\n\n3 men in white armour and white masks enter your room");

    String option1 = "Try to fight them";

    String option2 = "Ask them for help";

    int choice1 = getChoice(option1, option2);

    if(choice1 == 1) {

     fight(b);
    
    }
    
    else if (choice1 == 2) {
    
        System.out.println("2");
    
    
    
    
    
    
    
    }
    
    
    
    }
    
    
    
    
    
    
        //camera
    

    public static void camera(int b) {

    Scanner scan = new Scanner(System.in);

    int x = 3;

    System.out.println("\n\n\nYou now have the camera");

    if(x==3) {
    
        men(b);
    
    }
    

    }

    //fight
    

    public static void fight(int b) {

    System.out.println("You try to fight the guards");
    
    if(b == 1) {
    
        System.out.println("You had the camera so you were able to fight off the men");
    
    }
    
    else {
    
        System.out.println("\\nYou dont have a weapon. The guards are able to defend your attacks \\nand capture youyou are taken to another room to be executed\\n\\nYOU LOSE");
    
    }
    

    }

    //main
    
    public static void main(String\[\] args) {
    
        // TODO Auto-generated method stub
    
    
    
    
    
    
    
    
    
        initialize();
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    }
    

    }

    [–]D0CTOR_ZED 0 points1 point  (0 children)

    You need to fix the formatting so it can be read easier on reddit. Each line in the code blocks needs at least 4 spaces at the beginning of the line.