/**
* class Animal
simulates an animal and stores
* the species and name.
*
* @author D Newton
* @version Version 1, 1 November 2010
*/
public class Animal
{
// species of the animal e.g. lion, tiger
private String species;
// name of the animal e.g. Leo, Tommy
private String name;
/**
* Create an animal of the specified species and with the specified name
*
* @param species
a String
specifying the
* type of animal
* @param name
a String
specifying the
* name of animal
*/
public Animal(String species, String name)
{
this.species = species;
this.name = name;
}
/**
* Returns the species of the Animal
object
*
* @return the species of animal, as a String
*/
public String getSpecies()
{
return species;
}
/**
* Returns the name of the Animal
object
*
* @return the name of animal, as a String
*/
public String getName()
{
return name;
}
/**
* Returns a string representing the Animal
object. For a
* lion with name Leo it will return the String
"Leo, a lion"
*
* @return a String
representation of the animal
*/
public String toString()
{
return name + ", a " + species;
}
}