ReadingMaterialpublic class ReadingMaterial extends Object implements ExternalizableThe Externalizable Superclass:
When the Externalizable Subclass Book implements its writeExternal and
readExternal Methods, it needs to save the state of its superclass using
the superclass's writeExternal and readExternal Methods |
Fields Summary |
---|
private String | author | private String | subject | private int | yearwritten |
Constructors Summary |
---|
public ReadingMaterial()
| public ReadingMaterial(String auth, String sub, int year)Initialize the fields
author = auth;
subject = sub;
yearwritten = year;
|
Methods Summary |
---|
public java.lang.String | getAuthor()A public field access method, since the data fields are private and
will need to be accessed by the subclass to print them or use them
otherwise.
return author;
| public java.lang.String | getSubject()A field access method, since the data fields are private and will need
to be accessed by the subclass to print them or use them otherwise.
return subject;
| public int | getYearwritten()A field access method, since the data fields are private and will need
to be accessed by the subclass to print them or use them otherwise.
return yearwritten;
| public void | readExternal(java.io.ObjectInput in)Mandatory readExternal method. Will read in the data that we wrote out
in the writeExternal method. MUST BE IN THE SAME ORDER and type as we
wrote it out. By the time, readExternal is called, an object of this
class has already been created using the public no-arg constructor,
so this method is used to restore the data to all of the fields of the
newly created object.
author = (String)in.readObject();
subject = (String)in.readObject();
yearwritten = in.readInt();
| public void | writeExternal(java.io.ObjectOutput out)Mandatory writeExternal method.
out.writeObject(author);
out.writeObject(subject);
out.writeInt(yearwritten);
|
|