Codecheck.io
This illustrates many of the convention over configuration testing approaches of the new directory-less Codecheck.io. (Note: at least one .java file must have a public static void main(String[] args) method.)
CodecheckMainillustrates Codecheck.io's output-matching approach to unit tests by simplySOPing results calculated from generated or static test data or read from a.infile throughSystem.in.CodecheckTestis a Junit test suite run automatically, because the filename ends with 'Test' (or 'Test1', 'Test2', 'Test3', …).CodecheckTesterillustrates Codecheck.io's line pair output-matching approach to unit testing for filenames ending with 'Tester' (or 'Tester1', 'Tester2', 'Tester3', …) — every line has ':', every other line begins with 'Expected:', and value pairs following ':' must match.
To complete the assignment, complete the following methods and click CodeCheck at the bottom of the page:
- Complete the code for the
public static int square(int n)method in theCodecheckSquareclass that calculates the square ofn. - Complete the code for the
public static int cube(int n)method in theCodecheckCubeclass that calculates the cube ofn.
Include an initial comment with an @author YOUR NAME <your@email.address> line in all solution files.
Note: In APCS free-response-question CodeChecks there may be code on lines with a /**/ comment in the leftmost column — like this:
// There may be instance variables, constructors, and methods that are not shown.
/**/private String word;
/**/public HiddenWord(String word) { this.word = word; }
/**/public int length() { return this.word.length(); }
Any code on lines with a /**/ comment in the leftmost column has been added by the CodeCheck author(s) and is outside the scope of the APCS free-response question. That code is necessary to complete or test the program(s) and should not be modified, but there may be other valid implementations. Consequently, your solution cannot make assumptions about, nor make use of the knowledge of, any particular implementation of the added code.