Source of Person.java


  1: //Person.java
  2: 
  3: package javadocsample;
  4: 
  5: /**
  6:  * Class for a person
  7:  */
  8: public class Person
  9: {
 10:     private String name;
 11: 
 12: 
 13:     public Person()
 14:     {
 15:         name = "No name yet.";
 16:     }
 17: 
 18:     /**
 19:      * @param initialName the person's name
 20:      */
 21:     public Person
 22:     (
 23:         String initialName
 24:     )
 25:     {
 26:         name = initialName;
 27:     }
 28: 
 29:     /**
 30:      * @param newName the person's name is changed to newName
 31:      */
 32:     public void setName
 33:     (
 34:         String newName
 35:     )
 36:     {
 37:         name = newName;
 38:     }
 39: 
 40:     /**
 41:      * @return the person's name
 42:      */
 43:     public String getName()
 44:     {
 45:         return name;
 46:     }
 47: 
 48:     public void writeOutput()
 49:     {
 50:         System.out.println("Name: " + name);
 51:     }
 52: 
 53:     /**
 54:      * @return true if calling object and otherPerson have the same name.
 55:      */
 56:     public boolean sameName
 57:     (
 58:         Person otherPerson
 59:     )
 60:     {
 61:         return (this.name.equalsIgnoreCase(otherPerson.name));
 62:     }
 63: }