So far, our object-oriented solution includes six classes with their properties and methods. However, if we take another look at these six classes, we will notice that all of them have the same two methods:
calculatedPerimeter. The code for the methods in each class is different because each shape uses a special formula to calculate either the area or the perimeter. However, the declarations, contracts, or protocols for the methods are the same. Both methods have the same name, are always parameterless, and return a floating point value. Thus, all of them return the same type.
When we talked about the six classes, we said we were talking about six different geometrical shapes or simply shapes. Thus, we can generalize the required behavior or protocol for the six shapes. These shapes must define the
calculatedPerimeter methods with the previously explained declarations. We can create a protocol to make sure that the six classes provide the required behavior.