Using a generic class with two generic type parameters
We can create instances of the PartyWithDeeJay<AnimalElement, DeeJayElement> class by replacing both the AnimalElement and DeeJayElement generic type parameters with any type names that conform to the constraints specified in the declaration of the PartyWithDeeJay<AnimalElement, DeeJayElement> class. We have three concrete classes that implement both the AnimalProtocol and Equatable protocols: Dog, Frog, and Lion. We have one class that conforms to the DeeJayProtocol protocol: HorseDeeJay. Thus, we can use Dog and HorseDeeJay to create an instance of PartyWithDeeJay<Dog, HorseDeeJay>.
The following lines create a HorseDeeJay instance named silver. Then, the code creates a PartyWithDeeJay<Dog, HorseDeeJay> instance named silverParty and passes jake and silver as arguments. This way, we can create a party of dogs with a horse DJ, where Jake is the party leader, and Silver is the DJ. The code file for the sample...