Give an implementation of minus() for Vector solely in terms of the other Vector methods, such as direction() and magnitude(). Answer: The advantage of such implementations is that they limit the...


Give an implementation of minus() for Vector solely in terms of the other Vector methods, such as direction() and magnitude().


Answer:


The advantage of such implementations is that they limit the amount of detailed code to check; the disadvantage is that they can be inefficient. In this case, plus() and times() both create new Vector objects, so copying the code for plus() and replacing the minus sign with a plus sign is probably a better implementation.



Nov 27, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here