Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a class called Dog that represents a dog. The class should have fields re

ID: 3821713 • Letter: C

Question

Create a class called Dog that represents a dog. The class should have fields representing the dog's name, age, andbreed. Add two constructors to the class: 1) a no parameter constructor that sets the following as default values -- name: Spot, age: 1, breed: retriever and 2) a constructor that takes parameters for each field. Your class should not contain any other fields or methods at this point.

Using your design and implementation of the above Dog class, add appropriate accessor and mutator methods to the class. (You do not have to retype the entire class, just type out the new methods requested.)

Write a toString() method that displays the information about a Dog object in a nice format (you get to decide the actual format).

3 pts Cogth The the cogs. breed. And tw netructor to th to thy sets the fol default to that kee parameters 3 pts desip and lementathon ofth bove class ethods retype the entretlass, type out the methods recuested 2 prs that displays the infomation tcrmat.

Explanation / Answer

HI, Please find my implementation of Dog class.

Please let me know in case of any issue.

public class Dog {

  

   private String name;

   private int age;

   private String breed;

  

   public Dog() {

       name = "Spot";

       age = 1;

       breed = "retriever";

   }

   public Dog(String name, int age, String breed) {

       this.name = name;

       this.age = age;

       this.breed = breed;

   }

   // accessors and mutators

  

   public String getName() {

       return name;

   }

   public int getAge() {

       return age;

   }

   public String getBreed() {

       return breed;

   }

   public void setName(String name) {

       this.name = name;

   }

   public void setAge(int age) {

       this.age = age;

   }

   public void setBreed(String breed) {

       this.breed = breed;

   }

  

   @Override

   public String toString() {

       return "Name: "+name+", Age: "+age+", Breed: "+breed;

   }

  

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote