package myMain;

public enum Menum {

    ADD {

        public String calc(double a, double b) {

            return String.valueOf(a + b);
        }

    },

    SUB {

        @Override
        public String calc(double a, double b) {

            return String.valueOf(a - b);
        }

    },
    MUL {

        @Override
        public String calc(double a, double b) {

            return String.valueOf(a * b);
        }
    },
    DIV {

        @Override
        public String calc(double a, double b) {

            return String.valueOf(a / b + a % b);
        }
    };

    public abstract String calc(double a, double b);

    public static void main(String[] args) {

        mCalc(Menum.MUL, 4, 2);
    }

    public static void mCalc(Menum m, double a, double b) {

        String result = m.calc(a, b);
        System.out.println(result);
    }
}
分类: Java

毛巳煜

高级软件开发全栈架构师

工信部备案号:辽ICP备17016257号-2