Question: Design a class called Pet (the class file should be called Pet.java), with the following exact? fields/data members in this order: Field Description Example of

 Design a class called Pet (the class file should be called

Design a class called Pet (the class file should be called Pet.java), with the following exact? fields/data members in this order: Field Description Example of values Type The Type field holds the type of animal that the pet is Dog, Cat, Bird Legs The Legs field holds the number of legs of the pet Sound The sound field holds the sound the pet makes Meow, Bark, Chirp Name The Name field holds the name of the pet Spot, Fluffy color The Color field holds the color of the pet Age The Age field holds the age of the pet (in years) 1,9 The Pet class should also have the following exact methods in this order: Method Description setType T he setType method stores a value in the Type field getType The getType method returns the value of the Type field setlegs The setlegs method stores a value in the Legs field getlegs The getlegs method returns the value of the Legs field seisound The setsound method stores a value in the sound field The getsound method returns the value of the sound field setName The setName method stores a value in the Name field getName The getName method returns the value of the Name field setcolor The setColor method stores a value in the Color field getColor The getColor method returns the value of the Color field setage The setAge method stores a value in the Age field getage The getAge method returns the value of the Age 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 Color Type called Name who lived in Dallas, Texas in January 2020, when Nome wos Age years old. Name was a happy type and had long and happy life. Design a class called Cat (the class file should be called Cat.java) that extends the Pet class and override the setType method to set the Type to "Cat", setlegs to set the Legs to 4, and the setSound method to output "Meow". Design a class called Dog (the class file should be called Dog.java) that extends the Pet class and override the setType method to set the type to "Dog", setlegs to set the legs to 4, and the setSound method to output "Bark". Design a class called Bird (the class file should be called Bird.java) that extends the Pet class and override the setType method to set the type to "Bird", setLegs to set the legs to 2, and the setsound meth Once you have designed the 4 classes, design a program/project/driver class (the program/project/driver class file should be called Your NameAssignment1; replace Your Name with your actual name), add create and add the Pet, Cat, Dog, and Bird classes to the project. Then, inside the driver class main method, add code to: 1. Create the following 4 objects for the Cat, Dog and Bird classes: an object for a white Cat called Fluffy, an object for a orange tabby Cat called Tiger, an object for a black Dog called Bear, and an object for a blue Bird called Rio. Use the setName and setColor methods to set the name and color of the 4 pets and store the data into the 4 objects. 2. Prompt the user to enter (in a descriptive/user-friendly way) the ages of the 4 pets and store them into the 4 objects using the setAge methods. 3. Use the 4 objects' accessor methods (getType, getLegs, getsound, getName, getColor, and getAge methods) to retrieve the data from the 4 objects and confirm it/display/output it in the console, in a user-friendly way (e.g. "The name of the first cat is Fluffy"). 4. Call the 4 objects' PrintStory methods to print their 4 stories (e.g. "There once was a white cat called Fluffy who lived...")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!