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.
33 lines
1.0 KiB
33 lines
1.0 KiB
package com.cctv.news;
|
|
|
|
import com.cctv.news.command.*;
|
|
import com.cctv.news.controller.CommandController;
|
|
import com.cctv.news.view.ConsoleView;
|
|
import com.cctv.news.view.OutputView;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Scanner;
|
|
|
|
public class Main {
|
|
public static void main(String[] args) {
|
|
OutputView view = new ConsoleView();
|
|
List<String> articles = new ArrayList<>();
|
|
CommandController controller = new CommandController(view);
|
|
|
|
controller.registerCommand(new HelpCommand(view));
|
|
controller.registerCommand(new ListCommand(view, articles));
|
|
controller.registerCommand(new CrawlCommand(view, articles));
|
|
controller.registerCommand(new ExitCommand(view));
|
|
|
|
view.showWelcome();
|
|
view.showMessage("输入 help 查看可用命令");
|
|
|
|
Scanner scanner = new Scanner(System.in);
|
|
while (true) {
|
|
view.showPrompt();
|
|
String input = scanner.nextLine();
|
|
controller.executeCommand(input);
|
|
}
|
|
}
|
|
}
|
|
|