Kotlinlearncs.online LogoJava
Return to List

Test Writing: Simple Cat Inheritance

Created By: Geoffrey Challen
/ Version: 2020.10.0

Create a class named Cat. Cat should inherit from the Feliform class shown below:

(You do not need to define Feliform.)

You should provide a primary constructor that allows each Cat to be named (using a String) when it is created. You should not expose the name and do not need to allow it to be retrieved or modified. You should pass the type "cat" to the Feliform constructor when creating a Cat.

Cat should override toString and return a String in the following format: "(name) is the best cat".

Test Design Challenge

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

  • Provide a public class named TestCat with a single non-private class 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 Kotlin's assert or check methods