I'm not certain what I'm doing wrong here.
The code has no errors while compiling, and correctly prints the names and ages of the associated dog objects.
Note: It also fails to pass when I change the "return this.name;" and "return this.age" statements to "return name;" and "return age;" so that's not the reason why it's failing either.
package com.codegym.task.task05.task0503;
/*
Getters and setters for the Dog class
*/
public class Dog {
//write your code here
String name;
int age;
public void setName(String name) {
this.name = name;
}
public void setAge(int age) {
this.age = age;
}
public String getName(Dog d) {
return name;
}
public int getAge(Dog d) {
return age;
}
public static void main(String[] args) {
Dog dog1 = new Dog();
dog1.setName("Disco");
dog1.setAge(5);
Dog dog2 = new Dog();
dog2.setName("Bongo");
dog2.setAge(8);
System.out.println(dog1.getName(dog1));
System.out.println(dog1.getAge(dog1));
System.out.println(dog2.getName(dog2));
System.out.println(dog2.getAge(dog2));
}
}