Dealing with diversity relationships
A comfortable family life can lead to one or more "little ones" coming to this family. However, before adding a child to the family, make sure that the person has a real place to live. Give them a place to work, or a good summer vacation home. An address type should be able to solve all of these three places.
Listing 1. Add an address type to the person class
Package Com.tedneward.model
public class address
{
Public address ()
{
}
Public Address ( String Street, String city, string state, String Zip)
{
This.street = Street; this.city = city;
This.state = s Tate This.zip = Zip;
}
Public String toString ()
{
return ' [Address: +
' street= ' + street +] "+
" city= "+ City +" "+
" state= "+ state +" "+
" zip= "+ Zip +"] ";
}
Public int hashcode ()
{
return Street.hashcode () & City.hashcode ()
State.hashcode () & Zip.hashcode ();
}
Public boolean equals (Object obj)
{
if (obj = =)
Return this,
if (obj instanceof address) {
Address RHS = [address] obj;
return (This.street.equals (rhs.street) &&
This.city.equals ( rhs.city) &&
This.state.equals (rhs.state) &&
This.zip.equals (Rhs.zip));
}
Else
return false;
}
Public String Getstreet () {return this.street;
public void Setstreet (String value) {this.street = value;}
Public String getcity () {return this.city;}
public void setcity (String value) {this.city = value;}
Public String getState () {return this.state;}
public void SetState (String value) {this.state = value;}
Public String Getzip () {return this.zip;}
public void Setzip (String value) {this.zip = value;}
Private String Street;
Private String City;
Private String State;
Private String zip;
}