import java.io.*; import Statistics; import PersonName; import org.w3c.dom.*; public class Player implements Serializable { protected PersonName _name; protected Statistics _stats; protected int _number; protected String _highSchool; protected Grades _grades; public Player() { } /** * Return the name of a method that initializes * this JavaBean from a DOM tree. * Try this experiment: change this method to simply return the string "getJustAComment". * Then, run XMLBeanWriter on an instance of Player and see the result. * @return java.lang.String */ public String getDOMGetterName() { return null; } /** * Return the name of the method that initializes * this JavaBean from a DOM tree. * @return java.lang.String */ public String getDOMSetterName() { return null; } /** * Return the grade point average for this player. * @return float */ public double getGradePointAverage() { if (_grades != null) { return _grades.getGradePointAverage(); } else { return -1.0; } } /** * Return the grades for this player. * @return Grades */ public Grades getGrades() { return _grades; } public String getHighSchool() { return _highSchool; } /** * Use this method to demonstrate to yourself how getDOMGetterName() * works. Edit getDOMGetterName() to return the string "getJustAComment", and * the JavaBean you get will be simply a comment and nothing else. * @param doc org.w3c.dom.Document */ public DocumentFragment getJustAComment(Document doc) { DocumentFragment df = doc.createDocumentFragment(); Comment comment = doc.createComment("Since Player.getDOMGetterName returned " + "\"getJustAComment\", then that method created this comment"); df.appendChild(comment); return df; } public PersonName getName() { return _name; } public int getNumber() { return _number; } public Statistics getStats() { return _stats; } public void print() { System.out.println("Player\n-----"); System.out.print("Name: "); if (_name != null) { _name.print(); } else { System.out.println("null"); } System.out.println(""); System.out.println("High School:" + _highSchool); System.out.println("Number: " + _number); System.out.println("Grade point average: " + getGradePointAverage()); System.out.println("Statistics:"); if (_stats != null) { _stats.print(); } else { System.out.println("null"); } System.out.println(""); System.out.println("Grades:"); if (_grades != null) { _grades.print(); } else { System.out.println("null"); } } /** * Set the grades for this player. * @param grades Grades */ public void setGrades(Grades grades) { _grades = grades; } public void setHighSchool(String highSchool_) { _highSchool = highSchool_; } /** * Use this method to demonstrate to yourself how getDOMGetterName() * works. Edit getDOMGetterName() to return the string "getJustAComment", and * the JavaBean you get will be simply a comment and nothing else. * @param doc org.w3c.dom.Document */ public void setJustAComment(Element e) { } public void setName(PersonName name_) { _name = name_; } public void setNumber(int number_) { _number = number_; } public void setStats(Statistics stats_) { _stats = stats_; } }