import SimpleOutput; import SimpleInput; /** This "faux" class represents a textual user interface and is designed to work with the above classes. * * @author Amber McNett * @author Hisako Watanabe * @author Katt Thorne (in abstentia) * version 1.1 of February 2000 */ public class TUItestPrompt { // +--------+-------------------------------------------------- // | Fields | // +--------+ // player 1's name protected String name; // player 2's name protected String name2; // +------------+-------0--------------------------------------- // | Methods | // +-------------+ /** This is the main method which will begin the program and let it know * how many human players will be * playing. */ public void namer(String strg, String strg2) { SimpleOutput out = new SimpleOutput(); this.name = new String(strg); this.name2 = new String(strg2); out.println("Prompt is a success!");// the following // three lines are to show // the prompts are a success out.println("Player 1 is recorded as " + this.name + "."); out.println("Player 2 is recorded as " + this.name2 + "."); } public static void main(String[] args) { SimpleOutput out = new SimpleOutput(); SimpleInput in = new SimpleInput(); TUItestPrompt tuitp = new TUItestPrompt(); // OthelloTUI othtui = new OthelloTUI(); line will be added in real code int playnum; out.println("Welcome to CS152 Othello, version 1.0!"); out.println(" How many human players will be playing today?"); playnum = in.readInt(); while (playnum > 2 || playnum < 0) { out.println("Invalid number. Please enter again."); playnum = in.readInt(); } if (playnum == 0) { tuitp.namer("Computer 1", "Computer 2"); // following line: return othtui.run(); would be implemented // and would run the TUI program. } else if (playnum == 1) { out.println("Please enter your name: "); tuitp.namer(in.readString(), "Computer"); // following line: return othtui.run(); would be implemented // and would run the TUI program. } else { out.println("Please enter your name, player one: "); String play1 = in.readString(); out.println("Please enter your name, player two: "); String play2 = in.readString(); tuitp.namer(play1, play2); // following line: return othtui.run(); would be implemented // and would run the TUI program. } } // main } // OthelloTUI