
Concept explainers
Pet Class
Design a class named Pet, which should have the following fields:
- name. The name field holds the name of a pet.
- type. The type field holds the type of animal that a pot is. Example values are “Dog”, “Cat”, and “Bird”.
- age. The age field holds the pet’s age.
The Pet class should also have the following methods:
- setName. The setName method stores a value in the name field.
- setType. The setType method stores a value in the type field.
- setAge. The setAge method stores a value in the age field.
- getName. The getName method returns the value of the name field.
- gettype. The getType method returns the value of the type field.
- getAge. The getAge method returns the value of the age field.
Once you have designed the class, design a

Want to see the full answer?
Check out a sample textbook solution
Chapter 3 Solutions
Starting Out with Java: Early Objects (6th Edition)
Additional Engineering Textbook Solutions
Management Information Systems: Managing The Digital Firm (16th Edition)
Modern Database Management
SURVEY OF OPERATING SYSTEMS
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out with Python (4th Edition)
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning




