You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.5 KiB

package com.cctv.news.view;
public class ConsoleView implements OutputView {
private static final String ANSI_RESET = "\033[0m";
private static final String ANSI_CYAN = "\033[36m";
private static final String ANSI_RED = "\033[31m";
private static final String ANSI_GREEN = "\033[32m";
private static final String ANSI_MAGENTA = "\033[35m";
private static final String ANSI_YELLOW = "\033[33m";
private static final String PREFIX_INFO = ANSI_CYAN + "[INFO]" + ANSI_RESET + " ";
private static final String PREFIX_ERROR = ANSI_RED + "[ERROR]" + ANSI_RESET + " ";
private static final String PREFIX_ARTICLE = ANSI_GREEN + "[ARTICLE]" + ANSI_RESET + " ";
@Override
public void showMessage(String message) {
System.out.println(PREFIX_INFO + message);
}
@Override
public void showError(String error) {
System.out.println(PREFIX_ERROR + error);
}
@Override
public void showArticles(String articles) {
System.out.println(PREFIX_ARTICLE + articles);
}
@Override
public void showWelcome() {
System.out.println(ANSI_MAGENTA + "========================================" + ANSI_RESET);
System.out.println(ANSI_MAGENTA + " 央视新闻爬虫 v1.0" + ANSI_RESET);
System.out.println(ANSI_MAGENTA + "========================================" + ANSI_RESET);
}
@Override
public void showPrompt() {
System.out.print(ANSI_YELLOW + "请输入命令>" + ANSI_RESET + " ");
}
}