Design a class named Cylinder to represent cylinders. The class contains: ➤Two private double data fields named radius and length that specify the radius and length of a cylinder. The default values are 1.0 for radius and length. ➤ An int static data field named number OfObjects. The default value is 0. ➤ A no-arg constructor that creates a default cylinder. ▸ A constructor that creates a cylinder with the specified radius and length. ► Two sets of get and set methods for the two private data fields. ➤ A method named getArea() that returns the base area of the cylinder. ➤ A method named getVolume() that returns the volume of the cylinder. ➤ The static getNumberOfObjects method to return the data field number OfObjects. Requirements: 1. Draw the UML diagram for the class. Implement this class. The data fields should be private, and constructors and all other methods should be public. 2. Write a test program that should do the following tasks: ▸ create the first cylinder object using the no-arg constructor; ➤ create a second cylinder using the constructor with arguments to set radius to 2.5 and length to 12.3; ➤ create a third cylinder using the no-arg constructor; ➤ change the third cylinder's radius to 5.0 and length to 6.5. ➤ print out the radius and length of the first cylinder; ➤ print out the area of the second cylinder; print out the volume of the third cylinder. print out the value of the numOfObjects data field;
I already have the programming part done for this problem, just need help with making UML diagram. So please help create UML diagram for this problem.
I am pasting my program code underneath so you can copy paste and run it, so you don't need to create a program and attatching the instruction manual in the images so you know what is expected of the UML diagram.
1. Programm code for Cylinder class:
package homework;
public class Cylinder {
//Declare date fields
private double radius, length;
//Static date field
static int ObjectsCreated = 0;
//Constructor to create cylinder with default value of 1.0 for dimensions
public Cylinder() {
double radius;
double length;
this.radius = 1.0;
this.length = 1.0;
ObjectsCreated++;
}
//Constructor to create cylinder with specified radius and length
public Cylinder(double radius, double length) {
this.radius = radius;
this.length = length;
ObjectsCreated++;
}
//Functions to set values of cylinder's radius and length
public double getRadius(){
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public double getLength() {
return length;
}
public void setLength(double length) {
this.length = length;
}
//Computes area of cylinder
public double getArea() {
return Math.PI * radius * radius; //Area of cylinder
}
//Computes volume of cylinder
public double getVolume() {
return Math.PI * radius * radius * length; //Volume of cylinder
}
//Insert method to display amount of objects created
public static int AmountOfObjectsCreated() {
return ObjectsCreated;
}
}
2. Programm code for CylinderTest class:
package homework;
public class CylinderTest {
public static void main(String[] args) {
//Create cylinder using no argument constructors
Cylinder C1 = new Cylinder();
Cylinder C2 = new Cylinder(2.5,12.3);
Cylinder C3 = new Cylinder();
C3.setRadius(5.0);
C3.setLength(6.5);
//Display results of all cylinder
System.out.println("The radius of the first cylinder is: " + C1.getRadius() + " and the length is: " + C1.getLength());
System.out.println("The base area of the second cylinder is: " + C2.getArea());
System.out.println("The volume of the third cylinder is: " + C3.getVolume());
//Display number of objects made
System.out.println("The amount of objects created is: " + Cylinder.AmountOfObjectsCreated());
}
}
![### Cylinder Class Design and Implementation
#### Class Design:
Design a class named `Cylinder` to represent cylinders. The class contains:
- **Data Fields:**
- `private double radius` - specifies the radius of a cylinder (default: 1.0).
- `private double length` - specifies the length of a cylinder (default: 1.0).
- `private static int numberOfObjects` - tracks the number of cylinder objects created (default: 0).
- **Constructors:**
- A no-argument constructor that creates a default cylinder.
- A constructor that creates a cylinder with the specified radius and length.
- **Methods:**
- `public double getRadius()` - returns the radius of the cylinder.
- `public void setRadius(double radius)` - sets the radius of the cylinder.
- `public double getLength()` - returns the length of the cylinder.
- `public void setLength(double length)` - sets the length of the cylinder.
- `public double getArea()` - returns the base area of the cylinder.
- `public double getVolume()` - returns the volume of the cylinder.
- `public static int getNumberOfObjects()` - returns the number of cylinder objects created.
#### Requirements:
1. **UML Diagram:**
- Draw the UML diagram for the `Cylinder` class.
- Implement this class, ensuring data fields are private and constructors and methods are public.
2. **Test Program:**
- Create a test program that performs the following tasks:
- Create the first cylinder object using the no-argument constructor.
- Create a second cylinder using the constructor with arguments to set the radius to 2.5 and length to 12.3.
- Create a third cylinder using the no-argument constructor.
- Change the third cylinder’s radius to 5.0 and length to 6.5.
- Print out the radius and length of the first cylinder.
- Print out the area of the second cylinder.
- Print out the volume of the third cylinder.
- Print out the value of the `numberOfObjects` data field.
#### Explanation of UML and Test Program:
- **UML Diagram:**
The UML diagram visualizes the structure of the `Cylinder` class, with detailed specifications of the data fields and the methods. Make sure to diagram both the attributes (radius,](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F34215fe4-737d-4111-858a-1ca99d565feb%2F73fc79f0-c067-494b-aa5d-220ee70e9fd7%2Fga9e81n_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)