Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Could someone help me out. I am not sure what I should be doing. Seeing it worked out will allow me to understand what I
Could someone help me out. I am not sure what I should be doing. Seeing it worked out will allow me to understand what I should be doing and then I can complete it on my own.
Usando 2. Complete the Dog Class: a. Using the UML Class diagram to the right declare the instance variables. A text version is available: UML Class Diagram Text Version b. Create a constructor that incorporates the type, breed, and name variables (do not include topTrick) 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." c. Create the setTopTrick() mutator method. Dog type:string breed:string name:string top Trick:string setTop Trick(trick:string) toString() 3. Complete the Corgi classi a. Using the UML Class diagram, declare the instance variables. b. Create the two mutator methods for the instance variables. 4. Make sure to select the Project folder, then add a new class. Name it the Driver class, then create the code: a. There should be no instance variables. Corgi b. The main) method will be the only method in the class. weight:int c. Write three lines of code in the main) method: age:int i. Instantiate a corgi object using the below syntax setWeight(pounds.int) className object Name - new className input parameters) setAge(years:int) TIP: Refer to the constructors in the Dog and Corgi classes to ensure the input toStringo parameters are correct. ii. Use the objectName.setTopTrickl) method to set a top trick for the dog you created iii. Embed the objectName.toStrine) method in a statement that outputs to the console window 5. Once you have completed the code for the Dog and Corgi classes and created a Driver class, right-click the Project folder and select Run As, then Java 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. DogApp/DogApp: O Dog.java X Corgijava 1 public class Dog { // instance variables // constructor // methods NN HAPP OD 00 onih NO CON // method used to print Dog information public String toString() { String temp - " DOG DATA " + name + " is a " + breed + ", a " + type + " dog. InThe top trick is : " + TORTEick + "."; return temp; Declaration 22 Problems X e Javadoc 9 errors, 0 warnings, 0 others Description Errors (9 items) Resource Path Location DogApp/DogApp/Corgijava - Eclipse Dog.java Corgi java X 1 public class Corgi extends Dog { 77 additional instance variables 7e // constructor public Corgi (String type, String breed, String name, int pounds, int years) wo // invoke Dog class (super class) constructor super (typ breed.name).i. weight = pounds: age - years; // mutator methods // override toString method to include additional dog information @Override public String toString() { return (super.toString() + " The Corgi 19 " + age + + years old and weighs " + weight + " pounds."): Declaration & Problems x Javadoc 9 errors, 0 warnings, 0 others Description Errors (9 items) Resource Path Location Type
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started