public class Dog { /* Create a class named Dog based on the descriptions below. Each Dog has four properties that are only accessible from within the class. An example value is shown with each property. age – years old (3) name – (Fido) breed –(Poodle) color – (brown) Given a name, breed, and color, the Dog class will create a new instance of a brand new dog. Write a getter method for the age property. Write a setter method for the age property. Declare a variable named dog1 that references (points to) an instance of a Dog. Assume that all getters and setters have been implemented. Write code to create an object named dog1 that represents a 3 year old brown Poodle named Fido. System.out.println(dog1); If you created your dog correctly, the print statement above will produce the output below. Extend your Dog class such that dogs print as shown in the example below. Fido - 3 year old brown Poodle A dog young if the dog is less than 4 years old. Write a stub method in the Dog class that answers if a dog is young. Two dogs are equal if all properties have the same values. Write a method that answers if two dogs are equal. Dogs are compared based on their age. Write a method to compare two dogs.*/ //Instance Variables - Class Level Attributes private int age; private String name; private String breed; private String color; //Constructor public Dog(int _age, String _name, String _breed, String _color){ age = _age; name = _name; breed = _breed; color = _color; } //Getters -- attributes are private, we can't access them from other class public int getAge(){ return age; } //Setters - let's change public void setAge(int newAge){ age = newAge; } //toString() returns string formatted in a nice way public String toString(){ return "Name: " + name + "\nAge:" + age + "\nBreed:" + breed + "\nColor:" + color; } //If two dog objects have all the same stuffs they're equal public boolean equals(Dog doggie1){ //takes object of its class boolean result = false; if(age == doggie1.age && name.equals(doggie1.name) && breed.equals(doggie1.breed) && color.equals(doggie1.color)) result = true; return result; //one line solution!! //return age == doggie1.age && name.equals(doggie1.name) && breed.equals(doggie1.breed) && color.equals(doggie1.color) } //compares two doggos based on age public int compareTo(Dog doggie2){ //takes object of its class return age - doggie2.age; //current one minus the one passed in } }