выбери свое собственное приключение.не может выводить сообщение при вводе "freinds" - PullRequest
0 голосов
/ 19 февраля 2019
public static void main(String[] args) {
        // TODO Auto-generated method stub

        System.out.println("Choose your own adventure");
        System.out.println("For the past 3 months you have not been spending your money wisley");
        System.out.println("Due to your choices you have not been able to pay your bills");
        System.out.println("You are in a horrible postion and you are about to lose everything you own. The only way for you to survive is by making the right choices");
        System.out.println("What would you like to do? Make sure you think about your decsions more than once");
        System.out.println("Enter in one, two or three to start");

        Scanner scan1 = new Scanner(System.in);
        String optionone = scan1.nextLine();

        if (optionone.equals("one")) {
            System.out.println("its 2 am and you're stressed because you haven't paied your rent for the last two months. You're being kicked out in the next week if you don't pay the owner the money.");
            System.out.println("Enter in call, no rent, or drink to continue");
            optionone = scan1.nextLine();
            if (optionone.equals("call")) {
                System.out.println("You're desprate for money and while you're thinking of how to pay your rent your friend calls you who has just left from jail. He tells you to come to the place he is living at");
            }else if (optionone.equals("no rent")) {
                System.out.println("You choose not to pay your rent and you get kicked out of your apartment");
                System.out.println("Enter in friend to go to your friend's house or friend's house to go to his house");
            } else if (optionone.equals("friend")) {
                    System.out.println("You ask your friends if you can stay at their place, but you owe all of them hundreds of dollars. The only way to live with them is to pay them back which you cannot so now you're living in the streets. You have nothing to keep ypu warm and in 2 days you frezze to death");
                }else if (optionone.equals("drink")) {
                System.out.println("You choose to drink alcholo until you're so drunk you're knocked out. Unfortunatley, you also drank so many redbulls you ended up dying");
                System.out.println("Game ended");
            }
        }


// other story
        else if (optionone.equals("two")) { 
            System.out.println("You're staying up late to finish some work you have to finish and all of a sudden you get a call on your homephone and cellphone from an unknown caller ");


// other story
        }else  { ;
            System.out.println("Your are watching TV at 4 am instead of going to sleep at work and all of a sudden your lights go out");
        }
        String option2 = scan1.nextLine();
    }
}

1 Ответ

0 голосов
/ 20 февраля 2019

Вы уверены, что вводите его правильно?

Если процесс выглядит следующим образом:

"один", а затем "друг", вы должны получить сообщение

Вы спрашиваете своих друзей, можете ли вы остаться на их месте ...

Это работает для меня, поэтому убедитесь, что вы не печатаете что-то вроде 'freinds' или 'Friends',Вы специально проверяете «друг» и ничего больше.

Берегите себя и удачи.

РЕДАКТИРОВАТЬ: Чтобы уточнить, проблема заключается в утверждениях if.По сути, вы спрашиваете, набирает ли пользователь «один», а затем вводит «вызов», «без арендной платы», «напиток» или «друг».Он не проверяет, печатает ли пользователь «без арендной платы», а затем «друг».

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...