-
-
Save science/6426042 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
public class CodeRunner { | |
TestClass testClass = new TestClass(); | |
String answer_format = "Test1: %s\nTest2: %s"; | |
static String default_output_template = "Correct answers:\nTest1=%s\nTest2=%s\n"; | |
public static void main(String[] args) { | |
CodeRunner code = new CodeRunner(); | |
HashMap answers = code.tests(); | |
System.out.printf(default_output_template, answers.get("1"), answers.get("2")); | |
} | |
public HashMap tests() { | |
HashMap answers = new HashMap(); | |
answers.put("1", test_case1()); | |
answers.put("2", test_case2()); | |
return answers; | |
} | |
boolean test_case1() { | |
return testClass.main(1, 2) == 2; | |
} | |
boolean test_case2() { | |
return testClass.main(1, 2) == 3; | |
} | |
class TestClass { | |
public int main(int n1, int n2) { | |
return n1 + n2; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment