Problem with getting the code to return dog's age



sorry to bother you but I got stuck at the object oriented excercises (linked above). I'm trying to get the code to return the dog spike's age. After several erros I arrived at a code that at least returns some values...
But it still returns age as "0", even though it should be "9" (or should it?)
I'm really new to coding, and so I'm not sure what the problem might be (or even if this is the right kind of question). Please help...?

class Dog {
int age;
	public Dog(int dogsAge) {
  dogsAge = age;
  public void bark(){
  public void run(int feet){
   System.out.println("Your dog ran " + feet + " feet");
  public int getAge(){
    return age;

	public static void 
  main(String[] args) {

Dog spike = new Dog(9);
int spikeAge = spike.getAge();



Did you try,

age = dogsAge;



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.