1. Update the
printCarInfo method to print the string “Car undefined: no make specified.” if just
nil; “Car undefined: no model specified.” if just
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
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 ...