Java Graphs: Draw this graph using adjacent matrix and adjacent list: a.) Draw t
ID: 3813857 • Letter: J
Question
Java Graphs: Draw this graph using adjacent matrix and adjacent list:
a.) Draw the graph using adjacent matrix for ZooGraph. Store the vertex values in alphabetical order in an array.
b.) Draw the graph using adjacent list for ZooGraph. Store the vertex values in alphabetical order in an array.
A similar question has been posted before, but i'm not entirely sure the answer is correct. I would like to see someone else's answer to this problem for cross referencing purposes.
ZooGraph (V, E V(ZooGraph) {dog, cat, animal, vertebrate, oyster, shellfish, invertebrates crab, poodle, monkey, banana, dalmatian, dachshund E(ZooGraph) ((vertebrate, animal (invertebrate, anima (dog, vertebrate), (cat, vertebrate), monkey, vertebrate), (shellfish, invertebrate) (crab, shellfish), (oyster, shellfish), (poodle, dog), (dalmatian, dog), (dachshund, dog)Explanation / Answer
public category Bird implements Animal personal AnimalDetails animalDetails;
non-public final BirdTypeEnum birdTypeEnum;
public Bird(AnimalDetails animalDetails, BirdTypeEnum birdTypeEnum)
public String move() come birdTypeEnum.move();
// come birdTypeEnum.toString() + " fly";
}
public String getVoice() come birdTypeEnum.getVoice();
}
// getters and setters toString technique
}
The Animal Details is that the merely category with name, sex, size, age. My interface has the chance of victimisation polymorphism:
public interface Animal
The BirdTypeEnum sounds like this (the same for craniate and Fish):
public enum BirdTypeEnum implements AnimalType {
Eagle, Sparrow, Pigeon;
public String move() {
switch (this) {
case Eagle:
come Eagle.toString() + " fly";
case Pigeon:
come columbiform bird.toString() + " fly";
case Sparrow:
come Sparrow.toString() + " fly";
default:
come this.toString() + " fly";
}
}
public String getVoice() {
switch (this) {
case Eagle:
come Eagle.toString() + " provides voice";
case Pigeon:
come columbiform bird.toString() + " provides voice";
case Sparrow:
come Sparrow.toString() + " provides voice";
default:
come this.toString() + " provides voice";
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.