/**
 * EchoBot - The simplest possible chatbot
 * This example demonstrates a basic chatbot that repeats the user's message
 * with a confirmation.
 *
 * Part III of the book "Introduction to Programming in Java"
 */

public class EchoBot {
    private static final String BOT_TEMPLATE = "BOT: %s";
    private static final String USER_TEMPLATE = "USER: %s";

    /**
     * Method that responds to a user message.
     * @param message The user's message
     * @return The bot's response
     */
    public static String respond(String message) {
        // Concatenates the user's message with a standard response
        String botMessage = "I can hear you! You said: " + message;
        return botMessage;
    }

    public static void main(String[] args) {
        String userMessage = "Hello!";
        String response = respond(userMessage);
        System.out.println(String.format(USER_TEMPLATE, userMessage));
        System.out.println(String.format(BOT_TEMPLATE, response));
    }
}
