选择你自己的冒险。输入"freinds"时无法输出消息


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();
    }
}

您确定要正确地输入吗?

如果该过程如下:

"一个"然后"朋友",然后您应该得到消息

您问您的朋友您是否可以留在他们的地方...

它对我有用,因此请检查您没有输入诸如" Freinds"或"朋友"之类的内容。您正在专门检查"朋友",而没有其他检查。

保重和祝你好运。

编辑:要澄清,问题在于if语句。您本质上是在询问用户是否类型"一个",然后他们是否键入"呼叫","不租金","饮料"或"朋友"。它没有检查用户是否键入"不租金",然后是"朋友"。

最新更新