Kotlinlearncs.online LogoJava
Return to List

Test Writing: Make Chocolate

Imported By: Geoffrey Challen
/ Version: 2021.7.0

We want make a package of goal kilos of chocolate. We have small bars (1 kilo each) and big bars (5 kilos each). Return the number of small bars to use, assuming we always use big bars before small bars. Return -1 if it can't be done. No loops are needed to solve this problem!

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 makeChocolate(int small, int big, int goal) {
return 0; // You may need to remove this starter code
}