Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The code that I have says it has no output, but the assignment says it should have an output. Here are the requirements: For this

The code that I have says it has no output, but the assignment says it should have an output. Here are the requirements:

For this assignment, you wil complete the Dog application by completing the Dog and Corgi classes and creating the Driver class. Use theUploading Files to Eclipseand theDownloading Files From Eclipsetutorials to help you with this project.

  1. Open the Virtual Lab by clicking on the link in the Virtual Lab Access module. Then open your IDE and upload theDogApp.zipfolder containing the Dog and Corgi class files. You will be creating a Driver class in the same project folder. When you upload the files, you will see errors due to the classes being incomplete. As you complete each class, any errors should resolve.

  1. Complete the Dog class:
  2. Using the UML Class diagram to the right, declare the instance variables. A text version is available:UML Class Diagram Text Version.
  3. Create a constructor that incorporates the type, breed, and name variables (do not include topTrick).
  4. Note: The type refers to what the breed typically does; for example, a corgi would be a "cattle herding dog." A Shiba Inu would be a "hunting dog."
  5. Create the setTopTrick() mutator method.
  6. Complete the Corgi class:
  7. Using the UML Class diagram, declare the instance variables.
  8. Create the two mutator methods for the instance variables.
  9. Make sure to select the Project folder, then add a new class. Name it the Driver class, then create the code:
  10. There should be no instance variables.
  11. The main() method will be the only method in the class.
  12. Write three lines of code in the main() method:
  13. Instantiate a corgi object using the below syntax:
  14. className objectName = new className(input parameters)TIP:Refer to the constructors in the Dog and Corgi classes to ensure the input parameters are correct.
  15. Use the objectName.setTopTrick() method to set a top trick for the dog you created.
  16. Embed the objectName.toString() method in a statement that outputs to the console window.
  17. Once you have completed the code for the Dog and Corgi classes and created a Driver class, right-click the Project folder and selectRun As, thenJava Application. You should see output in the Console window that resembles the sample below. Your results will vary based on your input values.

Sample Output

DOG DATA

Java is a Pembroke Welsh Corgi, a cattle herding dog.

The top trick is: ringing the bell to go outside.

The Corgi is 5 years old and weighs 38 pounds.

Here is my code

public class Dog {

// class variables

private String type;

private String breed;

private String name;

private String topTrick;

// constructor

public Dog(String type, String breed, String name) {

this.type = type;

this.breed = breed;

this.name = name;

}

// methods

public void setType(String newType) {

type = newType;

}

public void setBreed(String newBreed) {

breed = newBreed;

}

public void setName(String newName) {

name = newName;

}

public void setTopTrick(String newTopTrick) {

topTrick = newTopTrick;

}

// method used to print Dog information

public String toString() {

String temp = "DOG DATA " +

this.name + " is a " + this.breed +

", a " + this.type +

" dog. The top trick is: " +

topTrick + ".";

return temp;

}

}

What is incorrect, and what am I missing from my requirements from the assignment?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions

Question

=+a. Should Germany accept this proposal?

Answered: 1 week ago