|
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
The next sequence of problems refer to the provided classes PhoneNumber and ContactInfo.
public class PhoneNumber { private String areaCode; private String exchange; private String extension; /** @return This PhoneNumber's area code. * You may abbreviate this "gAC()" */ public String getAreaCode() { return this.areaCode; } /** @return This PhoneNumber's exchange. * You may abbreviate this "gExch()" */ public String getExchange() { return this.exchange; } /** @return This PhoneNumber's extension * You may abbreviate this "gExt()" */ public String getExtension() { return this.extension; } /** Determine whether two PhoneNumbers represent the same phone. * @param * @return whether this PhoneNumber represents the same number as . */ equals( ) { } } |
/** A class to organize the contact info for a person. */ public class ContactInfo { private String name; private PhoneNumber homeNumber; private PhoneNumber workNumber; /** @return the person's home phone number. */ public PhoneNumber getHomeNumber() { // You an abbreviate this "gHN()" return this.homeNumber; } /** @return the person's work phone number. */ public PhoneNumber getWorkNumber() { // You can abbreviate this "gWN()". return this.workNumber; } /** Are `this' and `other' ContactInfos for two co-workers? * @param other The other contactInfo to compare with this one. * @return whether `other' is a co-worker of `this'. */ public boolean isCoworkerOf( ContactInfo other ) { } } |
ContactInfo ci1 = new ContactInfo( /* ... details omitted ... */ ); ContactInfo ci2 = new ContactInfo( /* ... details omitted ... */ ); ContactInfo ci3 = ci1; |
ci1.getName() == ci2.getName() // true or false?: ci1 == ci2; // true or false?: ci1 == ci3; // true or false?: ci3.setName( "Bobo" ); ci1 == ci3; // true or false?: ci1.swapWith(ci2); // Code not shown -- it might do anything ci1 == ci3; // true or false?: ci2 == ci3; // true or false?: |
(7pts) Every new Blopper contains a two brand-new Chorbles, one Doooozi (which must be specified separately for each Blopper), and the name of their favorite artist (which is initially "M.C. Hammer").
(If it makes you any happier, you can imagine replacing “Blopper” with “Kennel”, “Chorble” with “EmCee”, and “Doooozi” with “Dog”; the essence of the problem would be the same.)
1Or more realistically, that you are writing code which is inside an entirely different class/method. ↩
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
©2007, Ian Barland, Radford University Last modified 2007.Oct.24 (Wed) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |