Solution for Ch 8 Bronze Challenge in 2018


#1

The number of kids a parent has: Int or Int?

let numberOfKids: Int    // FaceB00K: Advertisers want to know.
let numberOfKids: Int?   // Cupertino: Respect your privacy. You can choose not to reveal.

The name of a person’s pet: String or String?

let petName: String?     // Not everyone has a pet.

#2

The phrase the name of a person’s pet implies that the person has a pet.

So, the problem could be tackled this way:

class Pet {
   let name : String
   ...
}

theirPets : [Pet]? // some people have at least one pet, some don't have any

Ditto for the children problem.