UML class diagrams are useful tools for mapping out different classes for an object-oriented program. The UML class diagram displays the attributes and methods of each class as well as shows relationships between classes. In this activity, you will analyze a UML class diagram and implement either the Cat or Dog class. The purpose of this activity is to give you practice interpreting UML class diagrams so that you will be prepared to implement the Pet Class for your Project One submission in Module Three.
Prompt
For this assignment, you will select either the Cat or Dog Java class from the UML diagram provided in Project One and implement it. Open the Virtual Lab by clicking on the link in the Virtual Lab Access module. Then open your IDE and create a new class. Use the Eclipse IDE and Downloading Files From Eclipse tutorials to help you with this project.
Review the UML Class Diagram, paying special attention to the class hierarchy, attributes, and behaviors. A text version of the UML Class diagram is available: UML Class Diagram Text Version.
Next, implement either the Cat or Dog Java class in the IDE. Your class must meet all the specifications from the UML Class diagram. Be sure to include the following in your Cat or Dog class:
All attributes with appropriate data structures
The Cat and Dog classes both have their own attributes (instance variables). For example, the Cat class has the catSpaceNbr attribute. In addition to the dog- and cat-specific attributes, they both inherit from the Pet class. This means the Dog and Cat classes will also have the seven attributes from the Pet class.
At least one constructor method
Accessors and mutators for all attributes
Each attribute should have a corresponding “set” and “get” method. For example, there will be a getPetType() and setPetType() method for the petType attribute. Make sure to do this for all attributes.
In-line comments and appropriate white space, according to the style guidelines you have learned so far in the course