日期:2014-05-20 浏览次数:21019 次
class TestFramework {
        .......... main()
        private static Sphere[] spheres;
        private static Sphere[] spheresBackup;
        String submissionName = args[0];
        Submission student =
                (Submission)Class.forName(submissionName).newInstance();
        ..........
        int[] studentResult = student.processFrame(x,y,z);
interface Submission {
        public int[] processFrame (double x,double y,double z) throws Exception;
}
class mySubmission implements Submission {
    
    //这里的构造方法应该怎样写才能获得TestFramework这个类的参数????
    
    public int[] processFrame( final double x,final double y,final double z) throws Exception {
    }
    
}
Class class = Class.forName(submissionName);
Constructor[] cons = class.getDeclaredConstructors();
if(cons[0].getParameterTypes().length>0){
    student = (Submission)cons[0].newInstance(new Object[]{new Integer(100),new Integer(200)});
}
------解决方案--------------------