Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions