Class Dog

java.lang.Object
  extended by Dog

public class Dog
extends java.lang.Object

A Dog has a name and an age, and a method to ageOneYear (and getters, setters, toString).

Version:
2006.Oct.08
Author:
Ian Barland

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

DOG_YEARS_PER_YEAR

double DOG_YEARS_PER_YEAR
Conversion factor from (real, human) years to dog-years

Constructor Detail

Dog

public Dog(java.lang.String _name,
           int _age)
Constructor for objects of class Dog.

Parameters:
_age - The initial age of the Dog.
_name - The initial name of the Dog.
Method Detail

ageOneYear

public void ageOneYear()
Have this dog become one year older.


getAge

public int getAge()
Getter for age.

Returns:
this Dog's age.

getAgeDogYears

double getAgeDogYears()
Return the age of the dog, in dog years.

Returns:
the age of the dog, in dog years.

getName

public java.lang.String getName()
Getter for name.

Returns:
this Dog's name.

getSound

java.lang.String getSound()
Getter for sound.

Returns:
this Dog's sound.

setAge

public void setAge(int _age)
Setter for age.

Parameters:
_age - The new age.

setName

public void setName(java.lang.String _name)
Setter for name.

Parameters:
_name - The new name.

swapAges

void swapAges(Dog otherDog)

testDog

static void testDog()
A function just to test my class Dog: create Dog instances, call methods on them, display them to the screen.


toInfoString

java.lang.String toInfoString()
Return a String representation of this Dog's fields.