Swift iOS Programming for Kids by Steffen D. Sommer

Swift iOS Programming for Kids by Steffen D. Sommer

Author:Steffen D. Sommer
Language: eng
Format: epub
Publisher: Packt Publishing


How cool is that? We just made two instances of a person communicate using the knowledge we acquired on OOP. In particular, note how the objects are communicating using the abstract Person type.

Adding more classes to the mix

Let's extend our program by introducing another class. We could add a Dog class to represent a dog that our persons are able to interact with. It could look something like this:

class Dog { var name: String var age: Int var breed: String init(name: String, age: Int, breed: String) { self.name = name self.age = age self.breed = breed } }

Very similar to our Person class, our new Dog class has the following properties:

name is the name of the dog

age is the age of the dog

breed is the breed of the dog



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.