利用接口做参数,写个计算器,能完成+-*/运算(1)定义一个接口Compute含有一个方法int computer(int n,int m);(2)设计四个类分别实现此接口,完成+-*/运算(3)设计一个类UseCompute,含有方法:public void useCom(Co ...
利用接口做参数,写个计算器,能完成+-*/运算
(1)定义一个接口Compute含有一个方法int computer(int n,int m);
(2)设计四个类分别实现此接口,完成+-*/运算
(3)设计一个类UseCompute,含有方法:public void useCom(Compute com, int one, int two)
此方法要求能够:1.用传递过来的对象调用computer方法完成运算2.输出运算的结果
(4)设计一个测试类,调用UseCompute中的方法useCom来完成+-*/运算
1 public interface Compute {2 3 int computer(int m,int n);4 5 }
原标题:接口—计算器
关键词:接口
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。