What would a UML Diagram look like for the program written below. Please include the "Shape", "Sphere", "Cylinder", "Cone" and the "shapeArray" classes. I still do not fully understand and I am trying to learn (first time creating one). Please and thank you! Source Code: package application; //abstract class "Shape" public abstract class Shape { //Declare two abstract methods publicabstractdouble surfaceArea(); //Calculate surface area of shape publicabstractdouble volume(); //Calculate volume of shape } package application; //class named "Sphere" that extends the "Shape" class public class Sphere extends Shape { //Attribute radius privatedoubleradius; // Constructor to initialize the sphere with a given radius public Sphere(doubleradius) { this.radius = radius; } @Override publicdouble surfaceArea() { return 4 * Math.PI * Math.pow(radius, 2); }   @Override publicdouble volume() { return (4 / 3.0) * Math.PI * Math.pow(radius, 3); } @Override public String toString() { return"Sphere - Surface Area: " + surfaceArea() + ", Volume: " + volume(); } } package application; //Class named "Cylinder" that extends the "Shape" class public class Cylinder extends Shape { //Attributes non-changeable privatefinaldoubleradius; privatefinaldoubleheight; privatestaticfinaldoublePI = Math.PI; // Constructor to initialize the radius and height attributes public Cylinder(doubleradius, doubleheight) { this.radius = radius; this.height = height; } // Overriding the surfaceArea() method to calculate the surface area of the cylinder. @Override publicdouble surfaceArea() { return (2 * PI * radius * height) + (2 * PI * Math.pow(radius, 2)); } // Overriding the volume() method to calculate the volume of the cylinder. @Override publicdouble volume() { returnPI * Math.pow(radius, 2) * height; } // toString() method returning the surface area and volume of the cylinder as a string @Override public String toString() { return"\nCylinder\n\tSurface Area: " + surfaceArea() + " sq.m\n\tVolume: " + volume() + " cubic m."; } } package application; //Class named "Cone" that extends the "Shape" class public class Cone extends Shape { //Attributes non-changeable privatefinaldoubleradius; privatefinaldoubleheight; privatestaticfinaldoublePI = Math.PI; // Constructor to initialize the radius and height attributes public Cone(doubleradius, doubleheight) { this.radius = radius; this.height = height; } // Overriding the surfaceArea() method to calculate the surface area of the cone. @Override publicdouble surfaceArea() { doubleslantHeight = Math.sqrt(Math.pow(radius, 2) + Math.pow(height, 2)); returnPI * radius * (radius + slantHeight); } // Overriding the volume() method to calculate the volume of the cone. @Override publicdouble volume() { return (1 / 3.0) * PI * Math.pow(radius, 2) * height; } // toString() method returning the surface area and volume of the cone as a string @Override public String toString() { return"\nCone\n\tSurface Area: " + surfaceArea() + " sq.m\n\tVolume: " + volume() + " cubic m."; } } package application; //Java GUI FX imports import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.VBox; import javafx.stage.Stage;   //Driver class ShapeArray public class ShapeArray extends Application { //Entry point for JavaFX application publicvoid start(Stage primaryStage) { // Creating instances for the different shapes: Sphere, Cylinder & Cone Sphere sphere = new Sphere(4); Cylinder cylinder = new Cylinder(2, 6); Cone cone = new Cone(5, 8);   // Storing the shape instances in an array Shape[] shapeArray = {sphere, cylinder, cone};   // Creating a vertical box layout VBox root = new VBox(); root.setPadding(new Insets(10));   // Iterating/looping through the shape array and creating labels for each shape's calculated data for (Shape shape : shapeArray) { Label shapeLabel = new Label(shape.toString()); root.getChildren().add(shapeLabel); } // Creating a scene with the layout and setting it to the stage Scene scene = new Scene(root, 300, 200); primaryStage.setScene(scene); primaryStage.setTitle("Shapes Surface Area & Volume Calculator"); primaryStage.show(); } // Launching application publicstaticvoid main(String[] args) { launch(args); } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

What would a UML Diagram look like for the program written below. Please include the "Shape", "Sphere", "Cylinder", "Cone" and the "shapeArray" classes. I still do not fully understand and I am trying to learn (first time creating one). Please and thank you!

Source Code:

package application;

//abstract class "Shape"

public abstract class Shape {

//Declare two abstract methods

publicabstractdouble surfaceArea(); //Calculate surface area of shape

publicabstractdouble volume(); //Calculate volume of shape

}

package application;

//class named "Sphere" that extends the "Shape" class

public class Sphere extends Shape {

//Attribute radius

privatedoubleradius;

// Constructor to initialize the sphere with a given radius

public Sphere(doubleradius) {

this.radius = radius;

}

@Override

publicdouble surfaceArea() {

return 4 * Math.PI * Math.pow(radius, 2);

}

 

@Override

publicdouble volume() {

return (4 / 3.0) * Math.PI * Math.pow(radius, 3);

}

@Override

public String toString() {

return"Sphere - Surface Area: " + surfaceArea() + ", Volume: " + volume();

}

}

package application;

//Class named "Cylinder" that extends the "Shape" class

public class Cylinder extends Shape {

//Attributes non-changeable

privatefinaldoubleradius;

privatefinaldoubleheight;

privatestaticfinaldoublePI = Math.PI;

// Constructor to initialize the radius and height attributes

public Cylinder(doubleradius, doubleheight) {

this.radius = radius;

this.height = height;

}

// Overriding the surfaceArea() method to calculate the surface area of the cylinder.

@Override

publicdouble surfaceArea() {

return (2 * PI * radius * height) + (2 * PI * Math.pow(radius, 2));

}

// Overriding the volume() method to calculate the volume of the cylinder.

@Override

publicdouble volume() {

returnPI * Math.pow(radius, 2) * height;

}

// toString() method returning the surface area and volume of the cylinder as a string

@Override

public String toString() {

return"\nCylinder\n\tSurface Area: " + surfaceArea() + " sq.m\n\tVolume: " + volume() + " cubic m.";

}

}

package application;

//Class named "Cone" that extends the "Shape" class

public class Cone extends Shape {

//Attributes non-changeable

privatefinaldoubleradius;

privatefinaldoubleheight;

privatestaticfinaldoublePI = Math.PI;

// Constructor to initialize the radius and height attributes

public Cone(doubleradius, doubleheight) {

this.radius = radius;

this.height = height;

}

// Overriding the surfaceArea() method to calculate the surface area of the cone.

@Override

publicdouble surfaceArea() {

doubleslantHeight = Math.sqrt(Math.pow(radius, 2) + Math.pow(height, 2));

returnPI * radius * (radius + slantHeight);

}

// Overriding the volume() method to calculate the volume of the cone.

@Override

publicdouble volume() {

return (1 / 3.0) * PI * Math.pow(radius, 2) * height;

}

// toString() method returning the surface area and volume of the cone as a string

@Override

public String toString() {

return"\nCone\n\tSurface Area: " + surfaceArea() + " sq.m\n\tVolume: " + volume() + " cubic m.";

}

}

package application;

//Java GUI FX imports

import javafx.application.Application;

import javafx.geometry.Insets;

import javafx.scene.Scene;

import javafx.scene.control.Label;

import javafx.scene.layout.VBox;

import javafx.stage.Stage;

 

//Driver class ShapeArray

public class ShapeArray extends Application { //Entry point for JavaFX application

publicvoid start(Stage primaryStage) {

// Creating instances for the different shapes: Sphere, Cylinder & Cone

Sphere sphere = new Sphere(4);

Cylinder cylinder = new Cylinder(2, 6);

Cone cone = new Cone(5, 8);

 

// Storing the shape instances in an array

Shape[] shapeArray = {sphere, cylinder, cone};

 

// Creating a vertical box layout

VBox root = new VBox();

root.setPadding(new Insets(10));

 

// Iterating/looping through the shape array and creating labels for each shape's calculated data

for (Shape shape : shapeArray) {

Label shapeLabel = new Label(shape.toString());

root.getChildren().add(shapeLabel);

}

// Creating a scene with the layout and setting it to the stage

Scene scene = new Scene(root, 300, 200);

primaryStage.setScene(scene);

primaryStage.setTitle("Shapes Surface Area & Volume Calculator");

primaryStage.show();

}

// Launching application

publicstaticvoid main(String[] args) {

launch(args);

}

}

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

For the diagram, are the classes "Sphere", "Cone", and "Cylinder" under the class "Shape"? And then the class "shapeArray" is under those classes? Is that how they all relate to one another? I have attached a rough UML diagram for clarity as to what I am trying to describe.

UML Diagram
Item 1
Item 2
Item 3
Sphere
Item 1
Item 2
Item 3
Item 1
Item 2
Item 3
Item 1
Item 2
Item 3
Shape
Cylinder
shapeArray
Item 1
Item 2
Item 3
Cone
Transcribed Image Text:UML Diagram Item 1 Item 2 Item 3 Sphere Item 1 Item 2 Item 3 Item 1 Item 2 Item 3 Item 1 Item 2 Item 3 Shape Cylinder shapeArray Item 1 Item 2 Item 3 Cone
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education