COMP 202 Lecture 27: COMP 202 - Lecture 27 - Nov 9, 2016
jc123 and 40170 others unlocked
100
COMP 202 Full Course Notes
Verified Note
100 documents
Document Summary
Write a method in the vector class that takes as input an array of vectors and returns the index of the vector with the largest magnitude. If there is a tie, return the smallest index. Non-static: v. indexoflargestmagnitude(vectors); we"re not doing anything to vector v, so this doesn"t really make sense. If we are going to be needing to access the magnitude of the vector a lot, we might want to have it as a property (to avoid recomputing it many times). Make it a new property public double magnitude; But then if we change the coordinate of a vector, the magnitude won"t change. We can prohibit the user to modify the vector points by letting the writer of the code know that they"re changing the vector class. So far, all of the attributes and methods that we have written have been public.