Question

The files at the links below contain source code for three interrelated classes, a Dog class,...

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 "Hotdog" is a 15 kg showdog that's a poodle. Write a statement that creates an owner for "HotDog" named Jill. Reference this person with the DogOwner variable jill 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);

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*
* 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 abc;

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 abc;


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 abc;


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);
}
}

Add a comment
Know the answer?
Add Answer to:
The files at the links below contain source code for three interrelated classes, a Dog class,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Below I have my 3 files. I am trying to make a dog array that aggerates...

    Below I have my 3 files. I am trying to make a dog array that aggerates with the human array. I want the users to be able to name the dogs and display the dog array but it isn't working. //Main File import java.util.*; import java.util.Scanner; public class Main {    public static void main(String[] args)    {    System.out.print("There are 5 humans.\n");    array();       }    public static String[] array()    {       //Let the user...

  • What is the output of running class C? The three Java classes are in separate Java...

    What is the output of running class C? The three Java classes are in separate Java files in the same directory (or in the same package). class A { public AO { System.out.println("The default constructor of A"); } // end A constructor } // end class A class B extends A { public BCString s) { System.out.println(s); } // end B constructor } // end class B public class C { public static void main(String[] args) { B b =...

  • Analyze the following code in these 2 Java classes and choose the correct statement below: public...

    Analyze the following code in these 2 Java classes and choose the correct statement below: public class Test { public static void main(String[] args) { Time1 time = new Time1(); time.print(); } } public class Time1 {    private String showTime;    public Time1(String newTime) { showTime = newTime; }    public void print() { System.out.printf("%s", showTime); } } a. The program will compile and run if you change: Time1 time = new Time1();  → Time1 time = new Time1("5:15"); b....

  • please debug this code: import java.util.Scanner; import edhesive.shapes.*; public class U2_L7_Activity_Three{ public static void main(String[] args){...

    please debug this code: import java.util.Scanner; import edhesive.shapes.*; public class U2_L7_Activity_Three{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); double radius; double length; System.out.println("Enter radius:"); double r = scan.nextDouble(); System.out.println("Enter length:"); double l = scan.nextDouble(); System.out.println("Enter sides:"); int s = scan.nextInt(); Circle c = Circle(radius); p = RegularPolygon(l , s); System.out.println(c); System.out.println(p); } } Instructions Debug the code provided in the starter file so it does the following: • creates two Double objects named radius and length creates...

  • What will the code shown below print to the console? public class Cascade public static void...

    What will the code shown below print to the console? public class Cascade public static void print(int arg){ for(int i=0; i<arg; i++){ System.out.print(""); } System.out.println(""); if(arg > 1){ print(arg-1); } } public static void main(String[] args) { print(4); } } E B IV AA- IES XX, SE V GT 12pt Paragraph -

  • The files provided in the code editor to the right contain syntax and/or logic errors. In...

    The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. // Start with a penny // double it every day // how much do you have in a 30-day month? public class DebugSix1 { public static void main(String args[]) { final int DAYS = 30; double money = 0.01; int day =...

  • Java Create four classes: 1.      An Animal class that acts as a superclass for Dog and...

    Java Create four classes: 1.      An Animal class that acts as a superclass for Dog and Bird 2.      A Bird class that is a descendant of Animal 3.      A Dog class that is a descendant of Animal 4.      A “driver” class named driver that instantiates an Animal, a Dog, and a Bird object. The Animal class has: ·        one instance variable, a private String variable named   name ·        a single constructor that takes one argument, a String, used to set...

  • Using C# Create an application class named LetterDemo that instantiates objects of two classes named Letter...

    Using C# Create an application class named LetterDemo that instantiates objects of two classes named Letter and CertifiedLetter and that demonstrates all their methods. The classes are used by a company to keep track of letters they mail to clients. The Letter class includes auto-implemented properties for the Name of the recipient and the Date mailed (stored as strings). Next, include a ToString() method that overrides the Object class’s ToString() method and returns a string that contains the name of...

  • In a project named 'DogApplication', create a class called 'Dog' 1. declare two instance variables in...

    In a project named 'DogApplication', create a class called 'Dog' 1. declare two instance variables in 'Dog' : name (String type) age (int type) 2. declare the constructor for the 'Dog' class that takes two input parameters and uses these input parameters to initialize the instance variables 3. create another class called 'Driver' and inside the main method, declare two variables of type 'Dog' and call them 'myDog' and 'yourDog', then assign two variables to two instance of 'Dog' with...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT