public interface IOperator
{
public double Calc(double x, double y);
}
public class Add : IOperator
{
public double Calc(double x, double y) => x+ y;
}
//not sure how to do it
public class Div : IOperator
{
public double Calc(double x, double y)
{
try
{
return x / y;
}
catch (Exception ex)
{
// make it in the program.cs that if this function gives 0 => to give "DivideByZeroException"
//Or find another solution
throw new DivideByZeroException("Deiasda");
return 0;
}
}
}
// not sure how to do it because the type is return double and not void
public class Mod : IOperator
{
//need to get modified, because of if u get 4 0 % the program should
public double Calc (double x, double y)
{
return x % y;
}
}
public class Multi : IOperator
{
public double Calc (double x, double y)=> x * y;
}
public class Sub : IOperator
{
public double Calc (double x, double y)=> x - y;
}