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.

52 lines
1.5 KiB

package view;
import model.Paper;
import command.Command;
import java.util.Scanner;
public class ConsoleView {
private Scanner scanner;
public ConsoleView() {
this.scanner = new Scanner(System.in);
}
public void displayWelcome() {
System.out.println("===== 学术论文爬虫程序 =====");
System.out.println("输入 help 查看可用命令");
System.out.println();
}
public String getInput() {
System.out.print("> ");
return scanner.nextLine().trim();
}
public void showInfo(String message) {
System.out.println("[INFO] " + message);
}
public void showSuccess(String message) {
System.out.println("[SUCCESS] " + message);
}
public void showError(String message) {
System.out.println("[ERROR] " + message);
}
public void showPaperInfo(int index, Paper paper) {
System.out.println(index + ". " + paper.getTitle());
System.out.println(" 作者: " + (paper.getAuthors() != null ? paper.getAuthors() : "未知"));
System.out.println(" 来源: " + (paper.getPlatform() != null ? paper.getPlatform() : "未知"));
System.out.println(" URL: " + (paper.getUrl() != null ? paper.getUrl() : "未知"));
System.out.println();
}
public void showCommandInfo(Command command) {
System.out.println(" " + command.getName() + " - " + command.getDescription());
}
public void close() {
scanner.close();
}
}