
package client;

import java.io.Serializable;
import compute.Task;

public class Operation implements Task<Integer>, Serializable {

    private static final long serialVersionUID = 1L;

    int a, b;
    String operand;

    public Operation(int a, int b, String operand) {
        this.a = a;
        this.b = b;
        this.operand = operand;

    }

    // do the operation
    public Integer execute() {
        return switch (this.operand) {
            case "+" -> a + b;
            case "-" -> a - b;
            case "*" -> a * b;
            case "/" -> a / b;
            default -> a % b;
        };
    }
}
