Create a UML class hierarchy (three connected UML diagrams) that has all three classes you created above. Make sure each UML diagram is a one-to-one to the code, it matches the Java code exactly. Make sure that both Child Classes point to their Parent. Hint: your subclasses are siblings.
Create a UML class hierarchy (three connected UML diagrams) that has all three classes you
created above. Make sure each UML diagram is a one-to-one to the code, it matches the Java
code exactly. Make sure that both Child Classes point to their Parent.
Hint: your subclasses are siblings.
Hint: You need to create three UML diagrams for three created Java classes and connect them
using arrows, where each Child Class points to its Parent. You can either draw this by hand and
take a picture or use a tool / software of your choice.
class Desktop extends Computer {
private int width;
private int height;
public Desktop() {
super();
width = height = 0;
}
public Desktop(String manufacturer, String diskSize, String manufacturingDate, int numberOfCores, int width, int height) {
super(manufacturer, diskSize, manufacturingDate, numberOfCores);
this.width = width;
this.height = height;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public void setWidth(int width) {
this.width = width;
}
public void setHeight(int height) {
this.height = height;
}
@Override
public String toString() {
return super.toString() + "\nWidth: " + width + " cm" + "\nHeight: " + height + " cm";
}
}
class Laptop extends Computer {
private double weight;
public Laptop() {
super();
weight = 0.0;
}
public Laptop(String manufacturer, String diskSize, String manufacturingDate, int numberOfCores, double weight) {
super(manufacturer, diskSize, manufacturingDate, numberOfCores);
this.weight = weight;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
@Override
public String toString() {
return super.toString() + "\nWeight: " + weight + " kg";
}
}
Step by step
Solved in 3 steps with 1 images