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);
/*
* 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);
}
}
The files at the links below contain source code for three interrelated classes, a Dog class,...
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...
Inheritance and Polymorphism (use Pet.java) You are given a class named Pet.java. Create two child classes named Cat.java and Dog.java. Cat.java should add attributes for color and breed. Dog.java should add attributes for breed and size (use String for small, medium, large). Add appropriate constructors, getter/setter methods and toString() methods. In a separate file named PetDriver.java, create a main. In the main, create an ArrayList of Pet. Add an instance of Cat and an instance of Dog to the ArrayList....
LAB: Pet information (derived classes)The base class Pet has private fields petName, and petAge. The derived class Dog extends the Pet class and includes a private field for dogBreed. Complete main() to:create a generic pet and print information using printInfo().create a Dog pet, use printInfo() to print information, and add a statement to print the dog's breed using the getBreed() method.Ex. If the input is:Dobby 2 Kreacher 3 German Schnauzerthe output is:Pet Information: Name: Dobby Age: 2 Pet Information: Name: Kreacher Age: 3 Breed: German SchnauzerPetInformation.javaimport java.util.Scanner; public class PetInformation { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Pet myPet = new Pet(); Dog myDog = new Dog(); String petName, dogName, dogBreed; int petAge, dogAge; petName = scnr.nextLine(); petAge = scnr.nextInt(); scnr.nextLine();...
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 =...
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. public class DebugTwo1 { public static void main(String[] args) { integer oneInt = 315; double oneDouble = 12.4; character oneChar = 'A'; System.out.print("The int is "); System.out.println(oneint); System.out.print("The double is "); System.out.println(onDouble); System.out.print("The char is "); System.out.println(oneChar); } }
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){
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 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 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 =...