/**
* CS1322: Programming Assignment #0 - Fall 2002
*
*
* Pet.java
* Class Pet - A Class designed to learn how to work with
* methods and javadoc.
*
* Revisions: 1.0 Aug. 26, 2002
* Created the Pet class
*
* 1.1 Aug. 26, 2002
* Finished, Compiled, Tested
*
*
* Collaboration Statement:
* I worked on the homework assignment alone, using only
* course materials.
*
* @author Jose Manuel Caban
* @version Version 1.1, Aug. 26, 2002
*/
public class Pet {
////////////////
//name methods//
////////////////
private String name;
/**
* Get the value of name
*
*
* @return value of name
*/
public String getName()
{
return name;
}
/**
* Set the value of name
*
*
* @param n value to assign to name
*/
public void setName(String n)
{
name = n;
}
///////////////
//age methods//
///////////////
private int age;
/**
* Get the value of age.
*
*
* @return value of age.
*/
public int getAge() {
return age;
}
/**
* Set the value of age.
*
*
* @param v Value to assign to age.
*/
public void setAge(int v) {
this.age = v;
}
//////////////////////
//animalType methods//
//////////////////////
private String animalType;
/**
* Get the value of animalType.
*
*
* @return value of animalType.
*/
public String getAnimalType() {
return animalType;
}
/**
* Set the value of animalType.
*
*
* @param v Value to assign to animalType.
*/
public void setAnimalType(String v) {
this.animalType = v;
}
/////////////////////////////////////////////////////////
/**
* Change standard string to output to be used for this specific program
*
*
* @return phrase as string
*/
public String toString()
{
return "My name is "+ getName() + "\n" +
"I am a "+getAnimalType()+" that is "+getAge()+" year"+((age>1)?"s ":" ")+
"old.";
}//added the plurality after seeing someone say it was fixed in the autograder
//so no points off!!!! yay!
/**
* Debugging main for class Pet.
*
*
* @param args IGNORED
*/
public static void main(String[] args) {
Pet fluffy = new Pet();
Pet fido = new Pet();
Pet mrBubbles = new Pet();
//Fluffy declarations (that sounds rather humorous doesn't it?)
fluffy.setName("Fluffy");
fluffy.setAge(3);
fluffy.setAnimalType("Cat");
//Fido declarations
fido.setName("Fido");
fido.setAge(5);
fido.setAnimalType("Dog");
//mrBubbles declaration
mrBubbles.setName("Mr. Bubbles");
mrBubbles.setAge(1); //give him another week
mrBubbles.setAnimalType("Fish");
//print to screen
System.out.println(fluffy);
System.out.println(fido);
System.out.println(mrBubbles);
}// end of main(String[] args)
}// end of class Pet