COMP 202 Lecture 27: COMP 202 - Lecture 27 - Nov 9, 2016

11 views2 pages
jc123 and 40170 others unlocked
COMP 202 Full Course Notes
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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents