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

Need help writing a java program called DogDemo class that reads in five pets of

ID: 3546063 • Letter: N

Question

Need help writing a java program called DogDemo class that reads in five pets of type Dog and displays the name and breed of all dogs that are over two tears old and have not had thier booster shots.

This is what i have so far.


public class Dog extends Pet
{
   private String breed = null;
   private boolean booster;

   public Dog()
   {
      super();
      breed = "undefined";
   }

   public Dog(String newBreed, boolean boosterShot)
   {
      booster = boosterShot;
      breed = newBreed;
   }

   public void reset(String newName, String newBreed, boolean boosterShot)
   {
      setName(newName);
      booster = boosterShot;
      breed = newBreed;
   }

   public String getBreed()
   {
      return breed;
   }
   
   public boolean getBooster()
   {
      return booster;
   }

   public void setBoosterShot(boolean newboosterShot)
   {
      booster = newboosterShot;
   }
   
   public void setBreed(String newBreed)
   {
      breed = newBreed;
   }

   public void writeOutput()
   {
      System.out.println("name: " + super.getName());
      System.out.println("age: " + super.getAge());
      System.out.println("weight: " + super.getWeight());
      System.out.println("boosterShot: " + getBooster());
      System.out.println("breedName: " + getBreed());
   }
}


public class Pet {
    public String name;
    private int age; //in years
    private double weight;//in pounds
    public Pet() {
        name = ".";
        age = 0;
        weight = 0;
    }
    
    public Pet(String initialName, int initialAge,
            double initialWeight) {
        name = initialName;
        if ((initialAge < 0) || (initialWeight < 0)) {
            System.out.println("Error: Negative age or weight.");
            System.exit(0);
        } else {
            age = initialAge;
            weight = initialWeight;
        }
    }
    public void setPet(String newName, int newAge,
            double newWeight) {
        name = newName;
        if ((newAge < 0) || (newWeight < 0)) {
            System.out.println("Error: Negative age or weight.");
            System.exit(0);
        } else {
            age = newAge;
            weight = newWeight;
        }
    }
    public Pet(String initialName) {
        name = initialName;
        age = 0;
        weight = 0;
    }
    public void setName(String newName) {
        name = newName; //age and weight are unchanged.
    }
    public Pet(int initialAge) {
        name = "No name yet.";
        weight = 0;
        if (initialAge < 0) {
            System.out.println("Error: Negative age.");
            System.exit(0);
        } else
            age = initialAge;
    }
    public void setAge(int newAge) {
        if (newAge < 0) {
            System.out.println("Error: Negative age.");
            System.exit(0);
        } else
            age = newAge;
//name and weight are unchanged.
    }
    public Pet(double initialWeight) {
        name = "No name yet";
        age = 0;
        if (initialWeight < 0) {
            System.out.println("Error: Negative weight.");
            System.exit(0);
        } else
            weight = initialWeight;
    }
    public void setWeight(double newWeight) {
        if (newWeight < 0) {
            System.out.println("Error: Negative weight.");
            System.exit(0);
        } else
            weight = newWeight; //name and age are unchanged.
    }
    public String getName() {
        return name;
    }
    public int getAge() {
        return age;
    }
    public double getWeight() {
        return weight;
    }
    public void writeOutput() {
        System.out.println("Name: " + name);
        System.out.println("Age: " + age + " years");
        System.out.println("Weight: " + weight + " pounds");
    }
}





Explanation / Answer

public class DogDemo { public static void main(String[] args) { Dog[] dogs = new Dog[5]; for (int i = 0; i
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