What is a Class Invariant?

A Class Invariant is a property of your data that must be maintained throughout the lifecycle of your class.


A Precondition is something that must be true before we call a function. This includes the parameters of the function.
public Shape(int numSides) {
   if(numSides < 1) {
      throw new RuntimeException("Number of sides must be positive");
   }
...
}
public static void main(String[] args) {
  //Test shape
  Shape s = new Shape(-1);
}