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

Hey There! need some help for my assignment if you can help out would be great..

ID: 3705150 • Letter: H

Question

Hey There! need some help for my assignment if you can help out would be great..

I have to create a program with a class called:  Dog,     and a driver class named: Kennel.

I need to have instance data for dog's name and dog's age.  Methods including the constructor, some "getters" and "setters" for name and age. Additional method to calculate the dog's age in human years *7.    Include a "toString" method to return a one-line description of dog

-Create constructor method to accept and initialize instance data

-instantiate four objects (instances) of Dog, setting up each dog

- create setters and getters method (example: setName(), and getName()...)

- toString() method to print dog's name and age when called by println()

- print statements for other information not using toString()

- calculate dog's age in person years

sample output should be

Print out all 4 dog's name and its age

Pick two dogs and give following info

                 example print line could be: "Happy Birthday Spitty. You are 9 years old"    (use method to get dog's name and dog's age)

example of another print line include: "Richard, you are now 45 in human years " (use method to get dog's name and use method to calculate his age-in-human-years)

  

Explanation / Answer

Kennel.java

public class Kennel {

public static void main(String[] args) {

Dog d1 = new Dog("Spitty", 5);

Dog d2 = new Dog("Chuchu", 6);

Dog d3 = new Dog("Dollar", 3);

Dog d4 = new Dog("Richard", 9);

System.out.println(d1);

System.out.println(d2);

System.out.println(d3);

System.out.println(d4);

System.out.println("Happy Birthday "+d1.getName()+". You are "+d1.getAge()+" years old");

System.out.println(d4.getName()+", you are now "+d4.calculateHumnaAge()+" in human years");

}

}

Dog.java

public class Dog {

private String name;

private int age;

public Dog() {

}

public Dog(String name, int age) {

this.name = name;

this.age = age;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

public int calculateHumnaAge() {

return age * 7;

}

@Override

public String toString() {

return "Dog [age=" + age + ", name=" + name + "]";

}

}

Output:

Dog [age=5, name=Spitty]
Dog [age=6, name=Chuchu]
Dog [age=3, name=Dollar]
Dog [age=9, name=Richard]
Happy Birthday Spitty. You are 5 years old
Richard, you are now 63 in human years