|
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
Remember: For Strings, use .equals (and not ==) to check whether two Strings both have the same sequence of characters.
Sometimes data-mining companies obtain two different records which both talk about the same person, even though some information is incomplete or not a complete match. (For instance, credit card companies want to know if the person
Holden Card, living at 123 House St., with phone number 540-321-9876is the same as
Holden A. Card, living at 123 House Street, with phone number 540-321-9876 and work number 540-123-4567.While it's dangerous to write an .equals which would consider the above to the same, certainly we could have a method likelyEquals that would identify such matches. (The data-mining company might have a human review such likely matches, to make a final decision.)
Your task: For ContactInfo, write a method probablyEqual, which returns true if the two instances have the same first & last name and the same address (but other fields may be different).
We mentioned that every field and method should be declared either public or private (as appropriate -- in today's lab, every field is private and every method is public). Add the appropriate adjective in front of every field and method declaration. (How does this change the auto-generated documentation?)
Similar to lect09b, include the following comment inside your .equals method:
// WARNING: We'll learn in week14: // the parameter-type for `equals' should actually be `Object'. |
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
©2007, Ian Barland, Radford University Last modified 2007.Aug.27 (Mon) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |