Kotlinlearncs.online LogoJava
Return to List

Test Writing: Simple Cat Inheritance

Created By: Geoffrey Challen
/ Version: 2020.10.0

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

(You do not need to define Feliform.)

You should provide a public constructor that allows each Cat to be named (using a String) when it is created. assert that the passed name is not null. You should not expose the name and do not need to provide either a setter or a getter for it. 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 Java's assert method