Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started