Skip to content
Snippets Groups Projects
Select Git revision
  • 0afc0a64393dc36aa9a29a0f21fc44007ceae8d1
  • master default
  • 2023
  • branche-avec-truc-style
  • branche-a-rebase
5 results

README.md

Blame
  • 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;
    	
    }