Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

45
LINES

< > BotCompany Repo | #1002515 // Java text game / UserInterface

Java source code

1  
// CSE 143 Homework 6: 20 Questions
2  
3  
/**
4  
 * Interface describing abstract user interaction operations.
5  
 * This interface is implemented by the graphical and text UIs for the game.
6  
 * Your QuestionTree interacts with the UI through this interface.
7  
 * @author Marty Stepp
8  
 * @version 2010/02/20
9  
 */
10  
public interface UserInterface {
11  
    /**
12  
     * Waits for the user to input a yes/no answer (by typing, clicking, etc.),
13  
     * and returns that answer as a boolean value.
14  
     * @return the answer typed by the user as a boolean (yes is true, no is false)
15  
     */
16  
    boolean nextBoolean();
17  
18  
    /**
19  
     * Waits for the user to input a text value, and returns that answer as a String.
20  
     * @return the answer typed by the user as a String (empty string if no answer typed)
21  
     */
22  
    String nextLine();
23  
    
24  
    /**
25  
     * Displays the given output message to the user.
26  
     * @param message The message to display.  Assumes not null.
27  
     */
28  
    void print(String message);
29  
    
30  
    /**
31  
     * Displays the given output message to the user.
32  
     * If the UI is a text UI, also inserts a line break (\n).
33  
     * @param message The message to display.  Assumes not null.
34  
     */
35  
    void println(String message);
36  
37  
    // various messages that are output by the user interface
38  
    // (your QuestionTree does not need to refer to these messages)
39  
    final String PLAY_AGAIN_MESSAGE = "Challenge me again?";
40  
    final String SAVE_MESSAGE = "Shall I remember these games?";
41  
    final String LOAD_MESSAGE = "Shall I recall our previous games?";
42  
    final String SAVE_LOAD_FILENAME_MESSAGE = "What is the file name?";
43  
    final String STATUS_MESSAGE = "Games played: %d\nI won: %d";
44  
    final String BANNER_MESSAGE = "Think of an item, and I will guess it.";
45  
}

download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002515
Snippet name: Java text game / UserInterface
Eternal ID of this version: #1002515/1
Text MD5: bcb8c497de6f19f72e6f667f5ffd7c4c
Author: stefan
Category:
Type: Java source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-01-29 18:33:23
Source code size: 1798 bytes / 45 lines
Pitched / IR pitched: No / No
Views / Downloads: 564 / 134
Referenced in: [show references]