Source of Person.java


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