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

The files at the links below contain source code for three interrelated classes,

ID: 3922040 • 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. DogTester.java DogOwner.java Dog.java Lancelot (formerly Chuckles) is an 8 kg spaniel who isn't a show dog. Lancelot starts to gain weight. Its weight goes up by 2 kg. Change Lancelot's weight accordingly in the main method in the DogTester class: public class DogTester { public static void main (String[] arg) { DogOwner jill; Dog d = new Dog("Hotdog", "poodle", 15.0, true); jill = new DogOwner("Jill", d); Dog c = new Dog("Chuckles", "spaniel", 8.0, false); jill.setDog(c); jill.setName("Darth"); jill.getDog().setName("Lancelot");

Explanation / Answer

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package chegg;

public class Dog {
  
private double weight;
private boolean show;
private String breed;
private String name;
  
public Dog()
{
weight = 0.0;
show = false;
breed = "";
name = "";
}
  
public Dog(String name,String breed,double weight,boolean show)
{
this.weight = weight;
this.breed = breed;
this.show = show;
this.name = name;
}
  
public void setWeight(double weight)
{
this.weight = weight;
}
  
public void setName(String name)
{
this.name = name;
}
  
public void setShow(boolean show)
{
this.show = show;
}
  
public void setBreed(String breed)
{
this.breed = breed;
}
  
  
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package chegg;


public class DogOwner {
private String name;
private Dog d;
  
public DogOwner()
{
name = "";
d = new Dog();
}
  
public DogOwner(String name,Dog d)
{
this.name = name;
this.d = d;
}
  
public Dog getDog()
{
return d;
}
  
public void setDog(Dog d)
{
this.d = d;
}
  
public void setName(String name)
{
this.name = name;
}
  
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package chegg;


public class DogTester {
public static void main (String[] arg)
{
DogOwner jill;
Dog d = new Dog("Hotdog", "poodle", 15.0, true);
  
jill = new DogOwner("Jill", d);
  
Dog c = new Dog("Chuckles", "spaniel", 8.0, false);
jill.setDog(c);
jill.setName("Darth");
  
jill.getDog().setName("Lancelot");
jill.getDog().setWeight(10.0);
}
}

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