Weight: 300 points. Please hand in via online
dropbox.
-
Book problems: 5.1.5, 6.1.1 (part 2), 6.3.1 (part 4), 6.3.2, 6.4.2, 6.5.2, 7.1.1, 7.1.3, 7.2.1, 7.5.1, 7.5.3.
-
In the textbook and in class, you've seen the contract and definition for a 2-dimensional (2D) position.
Following the design recipe, develop a notion of a 3D position and implement it with an appropriate struct definition.
Do the same for a 4D position. Then define a
"234-position" that encompasses all three. Develop and implement a
function that computes the distances between two "234-position"s. This
function can assume that the two incoming points have the same dimension.
Be particularly careful about how you define the contract for the "distance" function. Next, write a "distance-from-origin" function that takes any
"234-position" and returns the right type. Make sure you use the "distance" function that you have already defined in the earlier part of this exercise. Submit all intermediate
results, as well as materials showing that you have followed the design recipe.