Kotlinlearncs.online LogoJava
Return to List

Test Writing: Dominos

Created By: Chris Taylor
/ Version: 2023.7.0

Suppose we have a 2 x n checkerboard (two rows and n columns). Write the recursive method, dominos, that, given n, returns the number of possible ways in which we can cover the board with 1 x 2 dominos. For example:

            |
n = 1 -> 1  |

            ||   --
n = 2 -> 2  ||   --

            |||   --|   |--
n = 3 -> 3  |||   --|   |--

If n is less than zero, throw an IllegalArgumentException

Test Design Challenge

You're challenge is to write tests for this problem described above.

  • Provide a method named test that accepts no arguments and does not return a value.
  • If the implementation of the class described above is incorrect, your test method should throw an exception.
  • If it is correct, do not throw an exception.
  • You may want to use Java's assert method
int dominos(int n) {
return 0; // You may need to remove this starter code
}