接口实现运算

package com.youzuo.javaeye.first;

public interface Transportation {
	public abstract int speedTest(int fst,int scd,int thd);
}






package com.youzuo.javaeye.first;

public class ComputeTime {
	public static void main(String[] args) throws Exception{
		Transportation ts=(Transportation)(Class.forName(args[0]).newInstance()); 
		int common=0;
		common=ts.speedTest(Integer.parseInt(args[1]),Integer.parseInt(args[2]),Integer.parseInt(args[3]));
		System.out.println("这种交通工具的速度是"+common);
	}

}



package com.youzuo.javaeye.first;

public class Car implements Transportation{
	public int speedTest(int a,int b,int c)
	{
		return a*b/c;
		
	}
}




package com.youzuo.javaeye.first;

public class Plane implements Transportation{
	public int speedTest(int a,int b,int c)
	{
		return a+b+c;
	}
}

你可能感兴趣的:(java,C++,c,C#,交通)