001
002/**
003 * Cette classe a comme attribut un tableau de String contenant l'ensemble des commandes valides.
004 * @author  Gabriel Leroux aidé des enseignements de M.Bureau
005 * @version 23/03/2020
006 */
007public class CommandWords
008{
009    // a constant array that will hold all valid command words
010    private final String[] aValidCommands={"go","help","quit","look","ouvrir", "back", "test","prendre","deposer","jouer","charger","tirer","alea"};
011
012    /**
013     * Constructor - initialise the command words.
014     */
015    public CommandWords()
016    {
017
018    } // CommandWords()
019
020    /**
021     * Check whether a given String is a valid command word.
022     * @param pString prend en paramètre une String
023     * @return true if a given string is a valid command,
024     * false if it isn't.
025     */
026    public boolean isCommand( final String pString )
027    {
028        for ( int i=0; i<this.aValidCommands.length; i++ ) {
029            if ( this.aValidCommands[i].equals( pString ) )
030                return true;
031        } // for
032        // if we get here, the string was not found in the commands
033        return false;
034    } // isCommand()
035    /**
036     * Affiche toutes les commandes valides sur aGui.println
037     * @return une String contenant la liste des commandes valides
038     * 
039     */
040    public String getCommandList(){
041        String vCom="";
042        for(String command : aValidCommands){
043            vCom+=command + " ";
044        }
045        return vCom;
046    }
047} // CommandWords
048
049// ===== Methodes =====
050