Question: For this problem you are to join the following Java classes into a hierarchy according to Unified Modeling Language standards. If the parent class has
For this problem you are to join the following Java classes into a hierarchy according to Unified Modeling Language standards. If the parent class has the same attributes as the sub class then you can remove those attributes from the subclass.
| Pet - Super Class | ||
| Dog - Subclass | Cat - Subclass | Monkey - Subclass |
For the new subclass Monkey, add attributes: Height, double Eyes, string
For new subclass Cat, add attributes: Gender, string Size, int ** Please provide answer as all superclass/subclass code together. I think there are some constructor issues in my existing classes, if you can fix those as well. ** EXISTING SUPERCLASS PET: public class Pet { private String name; private int age; private String color;
public Pet(String name, int age, String color) { this.name = name; this.age = age; this.color = color; }
public String getName() { return name; }
public boolean setName(String name) { this.name = name; return true; }
public int getAge() { return age; }
public boolean setAge(int age) { this.age = age; return true; }
public String getColor() { return color; }
public boolean setColor(String color) { this.color = color; return true; }
@Override public String toString() { return "Pet [name=" + name + ", age=" + age + ", color=" + color + "]"; }
} EXISTING SUBCLASS DOG:
public class Dog { private String name; private int age; private String color; private String breed; private Double weight;
public Dog(String name, int age, String color, String name2, int age2, String color2, String breed, Double weight) { this.name = name; this.age = age; this.color = color; this.breed = breed; this.weight = weight; }
public String getName() { return name; }
public boolean setName(String name) { this.name = name; return true; }
public int getAge() { return age; }
public boolean setAge(int age) { this.age = age; return true; }
public String getColor() { return color; }
public boolean setColor(String color) { this.color = color; return true; }
public String getBreed() { return breed; }
public boolean setBreed(String breed) { this.breed = breed; return true; }
public Double getWeight() { return weight; }
public boolean setWeight(Double weight) { this.weight = weight; return true; }
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
