Skip to content

Instantly share code, notes, and snippets.

@douglasnomizo
Created September 3, 2013 15:05
Show Gist options
  • Save douglasnomizo/6425124 to your computer and use it in GitHub Desktop.
Save douglasnomizo/6425124 to your computer and use it in GitHub Desktop.
import java.util.HashMap;
public class CodeRunner {
Student student = new Student();
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 student.add(1, 2) == 2;
}
boolean test_case2() {
return student.add(1, 2) == 3;
}
class Student {
public int add(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