Question: which box(es) have the correct code? 12. Given the following code, which of the boxed choices will work as intended? (Assume allClientAnimals() returns an array

 which box(es) have the correct code? 12. Given the following code,

which box(es) have the correct code?

12. Given the following code, which of the boxed choices will work as intended? (Assume allClientAnimals() returns an array of Animal). Circle all choices that work. func walk(dog: Dog) { print("Walking (dog.name)") } func cleanLitterBox(cat: Cat) { print("Cleaning the \(cat.boxSize) litter box") } func cleanCage(bird: Bird) { print("Removing the \(bird.featherColor) feathers at the bottom of the cage") let pets = allClientAnimals() let pets = allClientAnimals() for pet in pets { if let dog = pet as? Dog { walk(dog: Dog) } else if let cat = pet as? Cat { cleanLitterBox(cat: Cat) } else { cleanCage(bird: Bird) } for pet in pets { if let dog = pet as! Dog { walk(dog: dog) } else if let cat = pet as! Cat { cleanLitterBox(cat: cat) } else if let bird = pet as! Bird { cleanCage(bird: bird) } } let pets = allClientAnimals() let pets = allClientAnimals() for pet in pets { if let x = pet as? Dog { walk(dog: x) } else if let x = pet as? Cat{ cleanLitterBox(cat: x) } else if let x = pet as? Bird { cleanCage(bird: x) } } for pet in pets { if pet is Dog { walk(dog: pet as! Dog) } else if pet is Cat cleanLitterBox(cat: pet as! Cat) } else if pet is Bird { cleanCage(bird: pet as! Bird) }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!