The files at the links below contain source code for three interrelated classes,
ID: 3600672 • Letter: T
Question
The files at the links below contain source code for three interrelated classes, a Dog class, a DogOwner class, and a DogTester class that manipulates objects from the other two classes. Dog Tester.java DogOwner.java Dog.java Hotdog, Jill's poodle, runs away, so Jill gets a new dog: Chuckles. Chuckles is an 8 kg spaniel who isn't a show dog. In the main method of the DogTester class create Chuckles and make Jill its new owner. Reference Chuckles using a new Dog variable c. public class Dog lester public static void main (StringlI arg) { DogOwner jill; Dog d new Dog("Hotdog", "poodle", 15.0, true); llnew DogOwner("Jill", d); /lend mairn end class CHECK ANSWERExplanation / Answer
Dog.java
public class Dog {
//Declaring variables
private String name;
private String breed;
private double weight;
private boolean isShowDog;
//Parameterized constructor
public Dog(String name, String breed, double weight, boolean isShowDog) {
super();
this.name = name;
this.breed = breed;
this.weight = weight;
this.isShowDog = isShowDog;
}
//getters and setters
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getBreed() {
return breed;
}
public void setBreed(String breed) {
this.breed = breed;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
public boolean isShowDog() {
return isShowDog;
}
public void setShowDog(boolean isShowDog) {
this.isShowDog = isShowDog;
}
//toString method is used to display the contents of an object inside it
@Override
public String toString() {
return " Dog Name=" + name + ", Breed=" + breed + ", Weight=" + weight + ", IsShowDog=" + isShowDog;
}
}
__________________
DogOwner.java
public class DogOwner {
//Declaring instance variables
private Dog dog;
private String ownerName;
//Parameterized constructor
public DogOwner(String ownerName, Dog dog) {
super();
this.dog = dog;
this.ownerName = ownerName;
}
//getters and setters
public Dog getDog() {
return dog;
}
public void setDog(Dog dog) {
this.dog = dog;
}
public String getOwnerName() {
return ownerName;
}
public void setOwnerName(String ownerName) {
this.ownerName = ownerName;
}
//toString method is used to display the contents of an object inside it
@Override
public String toString() {
return "OwnerName=" + ownerName + ", " + dog.toString();
}
}
__________________
DogTester.java
public class DogTester {
public static void main(String[] args) {
//Creating DogOwner class reference
DogOwner jill;
//Creating an instance of Dog class by passing some values arguments
Dog d = new Dog("Hotdog", "poodle", 15.0, true);
//Creating an Instance of DogOwner class and assigning the Dog to the Owner
jill = new DogOwner("Jill", d);
//Creating an instance of Dog class by passing some values arguments
Dog c = new Dog("Chuckles", "spaniel", 8, false);
//Setting the Owner to the Dog
jill.setDog(c);
//Setting the name of the Dog
jill.getDog().setName("Lancelot");
//Setting the weight of the Dog
jill.getDog().setWeight(c.getWeight() + 2);
//Displaying the Jill Dog Info After modifications
System.out.println(jill);
}
}
___________________
Output:
OwnerName=Jill, Dog Name=Lancelot, Breed=spaniel, Weight=10.0, IsShowDog=false
_____________Could you rate me well.Plz .Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.