Assignment 9, due Oct 29
Part of
the homework for 22C:60, Fall 2010
|
Always write your name legibly as it appears on your University ID and on the class list!
Given that p is some kind of point, p.setx(i) and p.sety(i) p.getx(i) and p.gety(i) access the x and y coordinates of p. These will be fast if p is a cartesian point, but slow if it is a polar points.
Similarly, p.setr(i) and p.settheta(i) p.getr(i) and p.gettheta(i) access the r and theta coordinates of p. These will be fast if p is a polar point, but slow if it is a cartesian point.
Note that the implementation of the cartesian point class would go in the file cartesianpoint.a and that the class descriptor for each class is a constant and therefore, the descriptor data structure for cartesian points can be part of cartesianpoint.a.
a) Give an appropriate header file, point.h, that defines the SMAL interface to any object of the polymorphic class point. (0.5 points)
b) Using your answer to part a) as a framework, and given that the local variable P in the current subroutine points to a point, write un-optimized SMAL Hawk code to set the x coordinate of that point to 55. (0.5 points)
c) Give appropriate SMAL code for the class descriptor shared by all cartesian points that should be part of cartesianpoint.a. (0.5 points)
d) Using your anwers above as a framework, give appropriate SMAL code to define the structure of a cartesian point object as seen by an outsider, appropriate to include in cartesianpoint.h, the public interface to cartesian points. (0.5 points)
e) Using your anwers above as a framework, give appropriate SMAL code to define the complete structure of a cartesian point object as seen by an the implementation of the cartesian point subclass, appropriate to include in cartesianpoint.a. (0.5 points)
f) Using your answers above) as a framework, write SMAL Hawk code for the setx method that would be part of cartesianpoint.a. (Writing settheta would be hard because of the need for trigonometry, but this one requires no computation. (0.5 points)