O'Reilly logo

Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming by Erica Sadun, Rod Strougo, Maurice Sharp

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Challenges

1. Update the printCarInfo method to print the string “Car undefined: no make specified.” if just make is nil; “Car undefined: no model specified.” if just model is nil; and keep printing “Car undefined: no make or model specified.” if both are nil. You can create test car objects using variations of the call to initWithMake:model:year:fuelAmount: from Listing 2-5 for checking your code.

2. Create a subclass of Car called ElectricCar. Take some time to design what that class might look like: the instance variables, modifications to existing methods, and any unique methods. When you have done that, either implement or read on for some possible approaches.

There are a few ways you could design the class for an electric car. Part of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required