172. Creating an electrical panel (hierarchy of classes)
Let’s assume that we want to model in code lines an electrical panel. Of course, we are not electricians, so for our purposes, an electric panel means a box with some internal circuits made of electrical components and a breaker that turns on/off the electrical panel.
Figure 8.1: Electrical panel components
Everything in an electrical panel can be considered an electrical component, so we can start our code by defining an interface that must be implemented by everything in this panel:
public interface ElectricComponent {}
Before continuing, let’s look at a diagram of the electric panel interfaces and classes that will help you to follow what comes after more easily:
Figure 8.2: A model of the electrical panel
An electrical panel consists of more electrical circuits that interact (or do not interact) with each other. We can represent such a circuit via an abstract
class as follows...