entreeSuivante
Calculatrice calc = new Calculatrice();
calc.ajouterOperation(new Operation() {
public int arite() { return 2; }
public double calcule(double... args) { return args[0] + args[1]; }
}, "+");
calc.ajouterOperation(new Operation() {
public int arite() { return 2; }
public double calcule(double... args) { return args[0] - args[1]; }
}, "-");
calc.ajouterOperation(new Operation() {
public int arite() { return 2; }
public double calcule(double... args) { return args[0] *args[1]; }
}, "*","x","X");
calc.ajouterOperation(new Operation() {
public int arite() { return 2; }
public double calcule(double... args) { return args[0] / args[1]; }
}, "/");
calc.ajouterOperation(new Operation() {
public int arite() { return 1; }
public double calcule(double... args) { return -args[0]; }
}, "~");
Operation
Calculatrice calc = new Calculatrice();
calc.ajouterOperation((x, y) -> x + y, "+");
calc.ajouterOperation((x, y) -> x - y, "-");
calc.ajouterOperation((x, y) -> x *y, "*","x","X");
calc.ajouterOperation((x, y) -> x / y, "/");
calc.ajouterOperation(x -> -x, "~");
Operation
ajouterOperation