Description
Overview
Nearly every Java application involves multiple classes. For this assignment, you will work on a Dog application composed of three classes. The Dog and Corgi classes have been started for you; you will complete these classes and create the Driver class from scratch. The application will be used to collect and print details about specific dogs. As you can see from the UML class diagram on this page, the Corgi class (child/subclass) inherits from the Dog class (parent/superclass). In the Corgi class file definition, the “extends” keyword is used to establish that it inherits from the Dog class.
Prompt
For this assignment, you will complete the Dog application by completing the Dog and Corgi classes and creating the Driver class. Use the Uploading Files to Eclipse and the Downloading Files From Eclipse tutorials to help you with this project.
- Open the Virtual Lab by clicking on the link in the Virtual Lab Access module. Then open your IDE and upload the DogApp.zip folder 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.
- Complete the Dog class:
- Using the UML Class diagram to the right, declare the instance variables. A text version is available: UML Class Diagram Text Version.
- 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.” - Create the setTopTrick() mutator method.
- Complete the Corgi class:
- Using the UML Class diagram, declare the instance variables.
- Create the two mutator methods for the instance variables.
- Make sure to select the Project folder, then add a new class. Name it the Driver class, then create the code:
- There should be no instance variables.
- The main() method will be the only method in the class.
- Write three lines of code in the main() method:
- Instantiate a corgi object using the below syntax:
TIP: Refer to the constructors in the Dog and Corgi classes to ensure the input parameters are correct.className objectName = new className(input parameters) - Use the objectName.setTopTrick() method to set a top trick for the dog you created.
- Embed the objectName.toString() method in a statement that outputs to the console window.
- Instantiate a corgi object using the below syntax:
- 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. |
Guidelines for Submission
Attach your completed Dog.java, Corgi.java, and Driver.java files to the assignment submission page.
Criteria | Exemplary (100%) | Proficient (85%) | Needs Improvement (55%) | Not Evident (0%) | Value |
---|---|---|---|---|---|
Dog Class | Modifies a class so that it includes all instance variables, a constructor method incorporating the prescribed variables, and a mutator method | Meets most “Proficient” criteria, but with minor errors; areas for improvement may include appropriate data structures or naming conventions | Meets some “Proficient” criteria, but with major errors or exclusions; areas for improvement may include functionality, syntax, or logic | Does not attempt criterion | 35 |
Corgi Class | Modifies a class so that it includes all instance variables and mutator methods for all instance variables | Meets most “Proficient” criteria, but with minor errors; areas for improvement may include appropriate data structures or naming conventions | Meets some “Proficient” criteria, but with major errors or exclusions; areas for improvement may include functionality, syntax, or logic | Does not attempt criterion | 25 |
Driver Class | Creates a class that includes a main() method, instantiates an object, calls a method from another class, and prints output | Meets most “Proficient” criteria, but with minor errors; areas for improvement may include syntax error, improper constructor, or outputting the wrong data | Meets some “Proficient” criteria, but with major errors or exclusions; areas for improvement may include functionality, syntax, or logic | Does not attempt criterion | 40 |
Total: | 100% |