Question: Java Draw a UML class diagram for the Exploring Inheritance exercise (including instance variables and methods). The codes are: public class Yorkshire extends Dog {

Java Draw a UML class diagram for the "Exploring Inheritance" exercise (including instance variables and methods).

The codes are:

public class Yorkshire extends Dog

{

private int breedWeight = 55;

public Yorkshire(String name)

{

super(name);

}

//-------------------------------------------------------------

//Small bark -- overrides speak method in Dog

//-------------------------------------------------------------

public String speak()

{

return "woof";

}

@Override

int avgBreedWeight() {

return breedWeight;

}

} /* Java Class: Dog

Class: CSCI 145

Description: Constructor for dog

I certify that the code below is my own work.

Exception(s): N/A

*/

//Labrador.java

//

//A class derived from Dog that holds information about

//a labrador retriever. Overrides Dog speak method and includes

//information about avg weight for this breed.

//

//****************************************************************

public class Labrador extends Dog

{

private String color; //black, yellow, or chocolate?

private int breedWeight = 75;

public Labrador(String name, String color)

{

super(name);

this.color = color;

}

//------------------------------------------------------------

//Big bark -- overrides speak method in Dog

//------------------------------------------------------------

public String speak()

{

return "WOOF";

}

//------------------------------------------------------------

//Returns weight

//------------------------------------------------------------

public int avgBreedWeight()

{

return breedWeight;

}

} /* Java Class: Dog

Class: CSCI 145

Description: Constructor for dog

I certify that the code below is my own work.

Exception(s): N/A

*/

// ****************************************************************

//Dog.java

//

//A class that holds a dog's name and can make it speak.

//****************************************************************

public abstract class Dog

{

protected String name;

//------------------------------------------------------------

//Constructor -- store name

//------------------------------------------------------------

public Dog(String name)

{

this.name = name;

}

//------------------------------------------------------------

//Returns the dog's name

//------------------------------------------------------------

public String getName()

{

return name;

}

//------------------------------------------------------------

//Returns a string with the dog's comments

//------------------------------------------------------------

public String speak()

{

return "Woof";

}

abstract int avgBreedWeight();

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!