Exercises
1. What will happen if you insert the message expression
[compResult reduce];
into Program 9.1 after the addition is performed? Try it and see.
2. Can the id variable dataValue, as defined in Program 9.2, be assigned a Rectangle object as you defined it in Chapter 8? That is, is the statement
dataValue = [[Rectangle alloc] init];
valid? Why or why not?
3. Add a print method to your XYPoint class defined in Chapter 8. Have it display the point in the format (x, y). Then modify Program 9.2 to incorporate an XYPoint object. Have the modified program create an XYPoint object, set its value, assign it to the id variable dataValue, and then display its value.
4. Based on the discussions about argument and return types in this chapter, modify ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access