Question: Consider the following class representing a Pet. Write a class for a Cat that is a subclass of Pet. In addition to a name and

Consider the following class representing a Pet.

Write a class for a Cat that is a subclass of Pet. In addition to a name and owner, a cat will have a breed and will say meow when it speaks. Additionally, a Cat is able to purr (print out Purring to the console).

public class Pet{

//creates a Pet with the given name & owner

public Pet(String name, String owner){

/* implementation not shown */

}

//returns the name of the current owner

public String getOwner()

{ /* implementation not shown */ }

//changes the owner of this Pet

public void changeOwner(String owner){

/* implementation not shown */ } //gets the name of this pet

public String getName()

{ /* implementation not shown */ }

//this pet has no sound, returns empty string

public String speak(){ /* implementation not shown */ }

//There may be other variables, constructors, and methods not shown. }

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!