# Code Samples

The following examples are used to illustrate this topic.

  1. Person - This simple class was used to introduce the idea of encapsulation (private fields with public getters and setters). This example uses a constructor for ensuring the state of an object when it is instantiated (created). In this topic, it is used to demonstrate unit testing.
  2. Account - This simple class also illustrates encapsulation, but with some of the fields being read-only. This class uses a constructor (which is also necessary for getting state into fields which do not have corresponding setter methods).
  3. Student - This class reinforces the idea of encapsulation and constructors. It also demonstrates the idea of overloading the default ToString() method that every class inherits from the Object class.
  4. Employee – The Employee class represents basic information about an employee of a company.
  5. Company - These are other classes similar to the Person and Student classes. These classes, however, "share" a driver, illustrating the fact that any given "program" typically uses more than one class.

Test Drivers (Console I/O)
TBA
Unit Tests (nUnit)
The unit tests for these classes are included in the solution folder under the "Demos + Practice" folder. Simply double-click the NUnit Test Project (.nunit) and the tests will open in the NUnit GUI.

Last updated on: 9/21/2019, 11:09:56 PM