Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Design a class called Pet (the class file should be called Pet.java), with the following fields Field Description Name The Name field holds the name
Design a class called Pet (the class file should be called Pet.java), with the following fields Field Description Name The Name field holds the name of the pet Type The Type field holds the type of animal that the pet is Dog", "Cat Example of values Spot, Fluffy "Rabbit", "Guinea pig", 'Turtle" 16.5, 3.0 "Bird" "Fish" Age The Age field holds the age of the pet (in years) Weight The Weight field holds the weight of the pet The Pet class should also have the following methods MethodDescription setName The setName method stores a value in the Name field getName The getName method returns the value of the Name field setType The setType method stores a value in the Type field getTypeThe getType method returns the value of the Type field setAge The setAge method stores a value in the Age field getAge The getAge method returns the value of the Age field setWeight The setWeight method stores a value in the Weight field getWeight The getWeight method returns the value of the Weight field Once you have designed the class, design a program/project/driver class that creates an objectofthe class Pet and promptthe user to enter (in a descriptive/user-friendly way1) the name, type, age, and weight of his or herpet. This data should be stored in the object. Use the object's accessor methods to retrieve the data from the object (the pet's name, type, age, and weight) and confirm it (display in on the screen, in a user- friendly way). You will need to add the class Pet to project and add your code to the project/driver class main method Follow the Assignment Code Convention For example, a message like "Please enter the age ofyourpet" or 'Please enter an integral numberrepresenting the age of your pet: "would allow the user to know what they should enter in a user-friendly way
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