Kotlinlearncs.online LogoJava
Return to List

Test Writing: No Teen Sum

Imported By: Geoffrey Challen
/ Version: 2021.7.0

Given three positive int values, return their sum. However, if any of the values is a teen—in the range 13..19, inclusive—then that value counts as 0, except 15 and 16 do not count as a teens. Complete and use the private helper method fixTeen and use it to apply the teen rule so that you don't need to repeat the same code three times.

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
private int fixTeen(int value) {
return value;
}
int noTeenSum(int first, int second, int third) {
return 0;
}