Please write in Java complier I am using is elcipse Write a

Please write in Java complier I am using is elcipse.

Write a class called Dog that contains instance data that represents the dog’s name and age. Define the Dog constructor to accept and initialize instance data. Include getter and setter methods for the name and age. Include a method to compute and return the age of the dog in “person years” (seven times the dog’s age). Include a toString method that returns a one-line description of the dog. Create a driver class called Kennel, whose main method instantiates and updates several Dog objects.

Example Output:

Console Kennel Java Application] C:\\Program Files Javalire1 Age: 4 Person-Yrs: 28 Dog: Spot Age: 1 Person-Yrs: 7 Dog: Fluffy Age: 7 Person-Yr: 49 Dog: Killer Age: 3 Person-Yrs: 21 Dog: King Tut Happy Birthday, Killer You are now 56 years old in person-years.

Solution

public class Dog
{
private int age;
private String name;
public Dog(int age,String name)
{
this.age = age;
this.name = name;
}
public String setDogName(String name)
{
this.name = name;
return name;
}
public int getDogName()
{
return age;
}
public int setDogAge(int age)
{
this.age = age;
return age;
}
public int getDogAge()
{
return age;
}
public int computeDogAge()
{
this.age = age*7;
return age;
}
public String toString()
{
String dogsname= \"Dog\'s name: \";
String dogsage= \"Dog\'s age: \";
return dogsname + name + \"\\t\" +
dogsage + age ;
}
public static void main (String[] args)
{
Dog dog1 = new Dog(1,\"Lucky\");
Dog dog2 = new Dog(2,\"Starc\");
Dog dog3 = new Dog(5,\"Lutchy\");
dog1.setDogAge(9);
System.out.println(dog1);
dog2.setDogName(\"Azzam\");
System.out.println(dog2);
System.out.println(dog3);
System.out.println();
System.out.println(\"Dog\'s ages in person+ years:\");
System.out.println(dog1.computeDogAge());
System.out.println(dog2.computeDogAge());
System.out.println(dog3.computeDogAge());
}
}

Please write in Java complier I am using is elcipse. Write a class called Dog that contains instance data that represents the dog’s name and age. Define the Dog
Please write in Java complier I am using is elcipse. Write a class called Dog that contains instance data that represents the dog’s name and age. Define the Dog

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site