Fund. CS II (CS152 2004F)

Homework 13: Extending Vectors

Due: Friday, 17 September 2004

Preparation: Make a copy of all the Sample Code. Put that code in the directory yourusername/newvec (below your normal code directory). Replace rebelsky by yourusername in each file.

a. Consider the new Vec2D method, boolean isNearby(Vec2D other, double close), which returns true if other is within close units of the current point and false otherwise. Add that method to the Vec2D interface and to and Update the test routine to test this method.

b. Write a method, fixAngle, for the Polar class. This method should ensure that the angle is between 0 and 2*pi. Test this method. What does your method do with an angle of -Math.PI/2? What does your method do with an angle of 23.2*Math.PI?

c. Update the constructor for Polar so that it calls fixAngle. Test your update.

Submission: Send me all of your files via electronic mail. Title the message CSC152 HW13: Your name.

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Wed Dec 8 10:36:52 2004.
The source to the document was last modified on Wed Sep 15 08:32:49 2004.
This document may be found at

You may wish to validate this document's HTML ; Valid CSS! ; Check with Bobby

Samuel A. Rebelsky,