Select Git revision
fichier_inutile
Forked from
ViaRézo / Formations / formation-git
Source project has a limited visibility.
Command.java 1.36 KiB
package Cli;
import java.util.ArrayList;
import Core.ActiveUserContext;
import Core.MyFoodora;
import Exception.ExceptionUnknownDishType;
import Exception.ExceptionUnknownMealType;
import Exception.ExceptionUnknownStartegyType;
import Exception.ExceptionUnknownTypeOfUser;
public abstract class Command {
private String commandName;
private Token [] listOfArgs;
public Command(String _commandName, Token [] _listOfArgs){
commandName = _commandName;
listOfArgs = _listOfArgs;
}
public boolean isOneWanted(String firstToken){
if(firstToken.toLowerCase().equals(commandName.toLowerCase()))
return true;
return false;
}
public boolean isGoodArgument(ArrayList<String> arguments) throws errorWrongNumberOfParams,errorWrongFormatValue{
if(arguments.size() != listOfArgs.length){
throw new errorWrongNumberOfParams("Error : "+Integer.toString(arguments.size())+" parameter insteed of "+Integer.toString(listOfArgs.length));
}
int i = 0;
for (String arg : arguments) {
listOfArgs[i].isTockenCorrect(arg); // throw une erreur, faut la catch au dessus !
i++;
}
// trow une erreur
return true;
}
public abstract void execute(ArrayList<String> arguments, MyFoodora foodora, ActiveUserContext activeUser) throws ExceptionUnknownMealType, NumberFormatException, ExceptionUnknownDishType, ExceptionUnknownStartegyType, ExceptionUnknownTypeOfUser;
}