Design a class named Pet, which have the following fields: • Name - name of the pet. • Animal - type of animal that a pet is (Dog, Cat, Bird). • Age - age of the pet. The Pet class should also have the following methods: • setName • setAnimal • setAge • getName • getAnimal .getAge a) Draw a UML diagram of the class. Be sure to include notation showing each field and method's access specification and data type. Also include notation showing any method parameters and their data types. b) Write the Java code for the Pet class. Create a main method in the same class and instantiate at least two objects of the class.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question
100%
Design a class named Pet, which have the following fields:
• Name - name of the pet.
• Animal - type of animal that a pet is (Dog, Cat, Bird).
• Age - age of the pet.
The Pet class should also have the following methods:
• setName
• setAnimal
• setAge
• getName
•.getAnimal
.getAge
a) Draw a UML diagram of the class. Be sure to include
notation showing each field and method's access specification and
data type. Also include notation showing any method parameters and
their data types.
b) Write the Java code for the Pet class. Create a main
method in the same class and instantiate at least two objects of the
class.
Transcribed Image Text:Design a class named Pet, which have the following fields: • Name - name of the pet. • Animal - type of animal that a pet is (Dog, Cat, Bird). • Age - age of the pet. The Pet class should also have the following methods: • setName • setAnimal • setAge • getName •.getAnimal .getAge a) Draw a UML diagram of the class. Be sure to include notation showing each field and method's access specification and data type. Also include notation showing any method parameters and their data types. b) Write the Java code for the Pet class. Create a main method in the same class and instantiate at least two objects of the class.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT