Kotlinlearncs.online LogoJava
Return to List

Test Writing: Table Equality

Created By: Pranav Narayanan
/ Version: 2026.10.0

Write a public class Table that has 3 variables: a String: wood, a double: width, and a double: height. You should implement a constructor that initializes these three variables in that order, rejecting null and zero/negative values. You should provide getters for all three variables.

You should also override .equals(), which should return true when two Tables have the same area.

Test Design Challenge

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

  • Provide a public class named TestTable 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
Report a Problem

Attribution must link to this page: https://www.learncs.online/testtesting/java/table-equality/[email protected]