Chapter 8:
1.
Physics students:
a. Overload the + operator to add Vector objects. Each Vector object has two attributes: a magnitude; and a direction (an angle
relative to the positive x-axis). The +
operator should return a new Vector object and should represent the vector sum
of two other Vector objects.
b. Overload the * operator to do the cross product of two vector
objects given in component form.
(You’ll be dealing with 3-dimensional vectors here.)
Chemistry students:
Overload the combine two Ions objects as a neutral compound. Each Ion object has an atomic symbol
attribute and a charge attribute. The +
operator should print the correct chemical formula. For example, if you have barium + chloride in the main, your
program should print BaCl2; ammonium
+ sulfate yields (NH4)2SO4, including the parentheses.
2.
Do chapter 8 problem #12.