Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ASSIGNMENT 1 Design a class called Pet (the class file should be called Pet Java). with the following fields: Field Description Name The Name field

image text in transcribed
ASSIGNMENT 1 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 Example of values Spot, Fluffy Type The Type field holds the type of animal that the pet is Dog Cat BirdFish" Age The Age field holds the age of the pet (in years) Height The Height field holds the height of the pet Weight The Weight field holds the weight of the pet Rabbit", "Guinea pig" "Turtle 1,9 2.5 16.5, 3.0 ' Legs?The Legsfieldholds the number of legs of the pet The Pet class should also have the following methods: Method Description setName The setName method stores a value in the Name field GetName The getName method returns the value of the Name field Setype The settype method stores a value in the Type field Geftype The gettype method returns the value of the Type field SeAge The setAge method stores a value in the Age field GetAge The getAge method returns the value of the Age field SetHeight The setHeight method stores a value in the Height field GetHeight The getHeight method returns the value of the Height field Setweight The setweight method stores a value in the Weight field Getweight The getWeight method returns the value of the Weight field Setlegs The selegs method stores a value in the Legs fielkd GetegsThe getlegs method returns the value of the Legs field PrintStory The Printstory method should display/output to the console the following message (inserting values for the class field into the appropriate location); There once was a TYPE named NAME who lived in Dallas, Texas. NAME was a LEGS legged pet. In 2017, when it was AGE years old, NAME was HEIGHT feet tall and WEIGHT pounds. NAME was a happy TYPE and hod long and happy life Once you have designed the class, design a program/project/driver class (the program/project/driver class file should be called [YourName)Assignmentl replace [YourName] with your actual name) that creates an object of the class Pet and prompt the user to enter (in a descriptive/user-friendly way?) the name, type, age, height, weight, and number of legs, of his or her pet. 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 the [YourNameJAssignment1 project and add your code to the project/driver class main method. Do not display the word NAME, AGE, etc in the story; replace them with the values for Name, Age, etc. from the class For example, a message like "Please enter the age of your pet "or "Please enter an integral number representing 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

1. What is Ebola ? 2.Heart is a muscle? 3. Artificial lighting?

Answered: 1 week ago

Question

=+4 Develop and deliver the CCT program.

Answered: 1 week ago

Question

=+5 Evaluate whether the CCT program was effective.

Answered: 1 week ago

Question

=+Identify the type of global assignment for which CCT is needed.

Answered: 1 week ago