package cs3500.connectn.consoleui; import cs3500.connectn.model.Player; import java.io.IOException; import java.util.InputMismatchException; /** * A synchronous view for Connect N. This interface does not depend on * the model or the controller. Instead, it learned the contents of the grid via * the {@code ViewModel} interface. By synchronous, I mean that this interface * assumes that the controller interacts with it synchronously—that is, * via ordinary, blocking method calls—but it does not require, say, that * the view be textual. * * @see ConsoleView */ public interface View { /** * Displays the state of the grid for the user. * * @throws IOException if writing the output throws * @param vm the contents of the grid */ void draw(ViewModel vm) throws IOException; /** * Asks the user to select a move and returns the response. * * @param who the player to ask (non-null) * @return the player's move * @throws IOException if writing the output throws * @throws InputMismatchException if the next token read cannot be parsed as * an {@code int} */ int readMove(Player who) throws IOException; /** * Reports that the user input could not be interpreter as an integer. * * @throws IOException if there's an IO error */ void reportNotANumber() throws IOException; /** * Reports to the user that the chosen column does not exist. * * @param maxColumn the highest in-bounds column number * @throws IOException if there's an IO error */ void reportColumnIndexOOB(int maxColumn) throws IOException; /** * Reports to the user that the chosen column is full. * * @param column the column number * @throws IOException if there's an IO error */ void reportColumnFull(int column) throws IOException; /** * Displays a message showing who won the game. * * @param winner the winning player (non-null) * @throws IOException if writing the output throws */ void announceWinner(Player winner) throws IOException; /** * Displays a message that no-one won the game. * * @throws IOException if writing the output throws */ void announceStalemate() throws IOException; }