Source of Animal.java


  1: /**
  2:  * A class to hold some information about an animal.
  3:  *
  4:  * @author Mark Young (A00000000)
  5:  */
  6: public class Animal {

  8:     /** Animal's name */
  9:     private String name;
 10:     /** Animal's species */
 11:     private final String SPECIES;

 13:     /** String representing a dog */
 14:     public static final String DOG = "dog";
 15:     /** String representing a hamster */
 16:     public static final String HAMSTER = "hamster";

 18:     /**
 19:      * Create an animal
 20:      *
 21:      * @param   species name of this Animal's species
 22:      * @param   name    name of this particular Animal
 23:      */
 24:     public Animal(String species, String name) {
 25:         this.SPECIES = species;
 26:         this.name = name;
 27:     }

 29:     /**
 30:      * Get this animal's species
 31:      *
 32:      * @return the species of the Animal
 33:      */
 34:     public String getSpecies() {
 35:         return SPECIES;
 36:     }

 38:     /**
 39:      * Get this animal's name
 40:      *
 41:      * @return the name of the Animal
 42:      */
 43:     public String getName() {
 44:         return name;
 45:     }

 47:     /**
 48:      * Change this animal's name
 49:      *
 50:      * @param   newName the new name of the Animal
 51:      */
 52:     public void setName(String newName) {
 53:         name = newName;
 54:     }

 56: }