supportsystem.java

来自「现在在国外大学里最流行的java学习软件,同时还有大量的example,在名为p」· Java 代码 · 共 72 行

JAVA
72
字号
/** * This class implements a technical support system. It is the top  * level class in this  project. The support system communicates via * text input/output in the text terminal. *  * This class uses an object of class InputReader to read input from * the user, and an object of class Responder to generate responses.  * It contains a loop that repeatedly reads input and generates output * until the user wants to leave. *  * @author     Michael Kolling and David J. Barnes * @version    0.2 */public class SupportSystem{    private InputReader reader;    private Responder responder;        /**     * Creates a technical support system.     */    public SupportSystem()    {        reader = new InputReader();        responder = new Responder();    }    /**     * Start the technical support system. This will print a welcome message and enter     * into a dialog with the user, until the user ends the dialog.     */    public void start()    {        boolean finished = false;        printWelcome();        while(!finished) {            String input = reader.getInput().trim().toLowerCase();            if(input.startsWith("bye")) {                finished = true;            }            else {                String response = responder.generateResponse();                System.out.println(response);            }        }        printGoodbye();    }    /**     * Print a welcome message to the screen.     */    private void printWelcome()    {        System.out.println("Welcome to the DodgySoft Technical Support System.");        System.out.println();        System.out.println("Please tell us about your problem. We will assist you");        System.out.println("with any problem you might have. Please type 'bye'");        System.out.println("to exit our system.");    }    /**     * Print a good-bye message to the screen.     */    private void printGoodbye()    {        System.out.println("Nice talking to you. Bye...");    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?