java.lang.Object Dog
public class Dog
A Dog has a name and an age, and a method to ageOneYear (and getters, setters, toString).
Field Summary | |
---|---|
(package private) double |
DOG_YEARS_PER_YEAR
Conversion factor from (real, human) years to dog-years |
Constructor Summary | |
---|---|
Dog(java.lang.String _name,
int _age)
Constructor for objects of class Dog. |
Method Summary | |
---|---|
void |
ageOneYear()
Have this dog become one year older. |
int |
getAge()
Getter for age. |
(package private) double |
getAgeDogYears()
Return the age of the dog, in dog years. |
java.lang.String |
getName()
Getter for name. |
(package private) java.lang.String |
getSound()
Getter for sound. |
void |
setAge(int _age)
Setter for age. |
void |
setName(java.lang.String _name)
Setter for name. |
(package private) void |
swapAges(Dog otherDog)
|
(package private) static void |
testDog()
A function just to test my class Dog: create Dog instances, call methods on them, display them to the screen. |
(package private) java.lang.String |
toInfoString()
Return a String representation of this Dog's fields. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
double DOG_YEARS_PER_YEAR
Constructor Detail |
---|
public Dog(java.lang.String _name, int _age)
_age
- The initial age of the Dog._name
- The initial name of the Dog.Method Detail |
---|
public void ageOneYear()
public int getAge()
double getAgeDogYears()
public java.lang.String getName()
java.lang.String getSound()
public void setAge(int _age)
_age
- The new age.public void setName(java.lang.String _name)
_name
- The new name.void swapAges(Dog otherDog)
static void testDog()
java.lang.String toInfoString()