Com S 342 --- Principles of Programming Languages EXERCISE 13: OBJECTS AND CLASSES (File $Date: 2005/04/18 05:07:33 $) The purpose of this exercise is for you to learn about object-oriented languages and the object-oriented interpreter. As with all exercises, this is to be done individually. And it is due the day this topic is planned to be discussed in class, unless specified otherwise (see the syllabus at: http://www.cs.iastate.edu/~cs342/syllabus.shtml). We expect this to help you think about the readings (see below). If you don't have an answer or an answer that you think is good, write down what you read, and a question or two that would have helped you make progress. Then you can ask that question in class; there will be other people with the same problem, and everyone can learn by discussing these issues. And you'll most likely see similar things on the homework, so it's best to understand them now. READINGS: Read chapter 5 of "Essentials of Programming Languages" (2nd ed., 2001) by Friedman, Wand, and Haynes, starting at page 115. Read the code carefully. 1. [Binary methods] a. Consider exercise 5.26 on page 202 of the text. What is wrong with the second piece of code written there, which is supposed to go in the colorpoint class? (Think about all kinds of calls on the method.) b. Could you fix this code using the instanceof expression described in problem 4 of homework 11 (see exercise 5.11 on page 199)? If so, show how that would be done in the defined language. 2. [fieldref, fieldset, and privacy] Consider the fieldref and fieldset expressions that are added to the defined langauge in homework 11, problem 5 (see exercise 5.14 on page 200 of the text). a. What kind of privacy (public, protected, and private) do these fieldref and fieldset expresions give to fields of objects? b. Briefly explain your answer, using an example. WHAT TO HAND IN You should have at the beginning of class, your answers to the above questions (or questions and problems you encountered for each part). Make sure your name is on these. Attach the printouts, if any, requested above.