Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 . Design an abstract class called YourNamePet with the following exact fields, methods, and functionality, in this order: Field / Method Description name A
Design an abstract class called YourNamePet with the following exact fields, methods, and functionality, in this order:
FieldMethod Description
name A private string field that holds the name of the pet eg Spot, Fluffy
type A private string field that holds the type of animal that the pet is eg dog, cat, bird, fish, rabbit
YourNamePet A constructor with parameters name and type that initializes the fields with the corresponding parameters values.
sound An abstract void method that output the sound the pet makes.
eat A void method that outputs Eating
sleep A void method that outputs Sleeping
toString A string method that returns a string with the format: NAMEname, TYPEtype where name and type are the fields values.
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