Skip to content
Snippets Groups Projects
Select Git revision
  • 92af420efec4ca630fa3777cdf8bf3f9d541d13e
  • main default
  • tp3
  • tp2
  • tp1
  • tp3-correction
  • tp2-correction
  • tp1-correction
  • admins
9 results

calculator.py

Blame
  • Forked from an inaccessible project.
    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;
    	
    }