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
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