编辑代码

import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {

        System.out.println("*******************************");
		System.out.println("*******Library ADVENTRUE*******");
        System.out.println("*******************************");

        String password = "12345";
        String text = "";
        String legacy = "";
        Boolean getBook = false;
        Boolean doorOpened = false;
        Boolean one = false, two = false, three = false, four = false, five = false;
        // 使用 System.in 创建 BufferedReader
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Do you want to enter the library?");
        System.out.println("Enter \'yes\' if you want, \'no\' if you do not.");
        // 读取字符
        do {
            legacy = text;
            text = br.readLine();
            if (text.equals("yes")) {
                System.out.println("Entered library");
                System.out.println("Do you want to read the books? \'y\' for yes, \'n\' for no");
            } else if (text.equals("no")) {
                System.out.println("You left the library, game OVER");
                break;
            } else if (one && two && three && four && five) {
                System.out.println("Magic DOOR opened.");
                System.out.println("Please enter the password:");
                doorOpened = true;
                one = false;
            } else if (doorOpened) {
                if (text.equals(password)) {
                    System.out.println("You completed the library god's puzzle, YOU WIN!!!");
                    break;
                } else {
                    System.out.println("password incorrect, try again");
                }
            } else if (text.equals("y") && legacy.equals("yes")) {
                getBook = true;
                System.out.println("Please pick from Book 1-5: ");
            } else if (text.equals("n") && getBook) {
                System.out.println("You reject the library god, game OVER");
                break;
            } else if (text.equals("1") && getBook) {
                System.out.println("<-----You are now reading book 1----->");
                System.out.println("Description:");
                System.out.println("hi");
                one = true;
            } else if (text.equals("2") && getBook) {
                System.out.println("<-----You are now reading book 2----->");
                System.out.println("Description:");
                System.out.println("hello");
                two = true;
            } else if (text.equals("3") && getBook) {
                System.out.println("<-----You are now reading book 3----->");
                System.out.println("Description:");
                System.out.println("bonjour");
                three = true;
            } else if (text.equals("4") && getBook) {
                System.out.println("<-----You are now reading book 4----->");
                System.out.println("Description:");
                System.out.println("salute");
                four = true;
            } else if (text.equals("5") && getBook) {
                System.out.println("<-----You are now reading book 5----->");
                System.out.println("Description:");
                System.out.println("hej");
                five = true;
            } else if (one && two && three && four && five) {
                System.out.println("Magic DOOR opened.");
                System.out.println("Please enter the password:");
                doorOpened = true;
                one = false;
            }
        } while (!text.equals("end"));
	}
}