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;

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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,
Transcribed Image Text:### 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,
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY