class Person // Fig 4.1, page 91
{
public
Person( String n, int ag, String ad, String p )
{ name = n; age = ag; address = ad; phone =
p; }
public String
toString( )
{return
getName( ) + " " + getAge( ) + " " + getPhoneNumber(
); }
public final
String getName( )
{ return name; }
public final
int getAge( )
{ return age; }
public final
String getAddress( )
{ return address; }
public final
String getPhoneNumber( )
{ return phone; }
public final
void setAddress( String newAddress )
{ address = newAddress; }
public final
void setPhoneNumber( String newPhone )
{ phone = newPhone; }
private
String name;
private int
age;
private
String address;
private
String phone;
}
class Student extends Person // Fig 4.8, page 102
{
public
Student( String n, int ag, String ad, String p, double g )
{
super( n,
ag, ad, p );
gpa =
g;
}
public String
toString( )
{
return
super.toString( ) + " " + getGPA();
}
public double
getGPA( )
{
return
gpa;
}
private
double gpa;
}