Please conduct the following tasks alone. For implementation details you can refer to the lecture slides or the Apple developer website. Please do not hesitate to ask me or the tutor if you have any questions. Under “Tip” you can find some hints for the task. The “Checklist” specifies what should happen when your implementation is correct.
Extend your previously created Person class and add a custom initializer method that sets the first name and last name Properties right on object creation.
Currently the person is unfriendly because it is not able to say hello. Create a FriendlyPerson protocol that specifies a few methods that make a friendly person. Let the person class implement the protocol and call some of the friendly methods.
As the last step, create a Person instance and test the implementation
You can define the FriendlyPerson protocol in the Playground just before the Person class.
Checklist | |
---|---|
A person has a custom initializer | |
The person is a friendly person because it follows the protocol |