Every cylinder has a base and height, where the base is a circle. Design the class Cylinder that can capture the properties of a cylinder and perform the usual operations on a cylinder. Derive this class from the class Circle (done through Problem 3.2). Please do the following: Some of the operations that can be performed on a cylinder are as follows: calculate and print the volume, calculate and print the surface area, set the height, set the radius of the base, and set the center of the base. Write a test program to test your program. Note: Java programming. Please also send the test program so I can run it in dr java and learn. Use given code and design the class cylinder that can capture the properties of a cylinder and perform the usual operations on a cylinder. Point code: // class Point public class Point { protected double x, y; // coordinates of the Point //Default constructor public Point() { setPoint( 0, 0 ); } //Constructor with parameters public Point(double xValue, double yValue ) { setPoint(xValue, yValue ); } // set x and y coordinates of Point public void setPoint(double xValue, double yValue ) { x = xValue; y = yValue; } // get x coordinate public double getX() { return x; } // get y coordinate public double getY() { return y; } // convert point into String representation public String toString() { return "[" + String.format("%.2f", x) + ", " + String.format("%.2f", y) + "]"; } //Method to compare two points public boolean equals(Point otherPoint) { return(x == otherPoint.x && y == otherPoint.y); } //Method to compare two points public void makeCopy(Point otherPoint) { x = otherPoint.x; y = otherPoint.y; } public Point getCopy() { Point temp = new Point(); temp.x = x; temp.y = y; return temp; } // print method public void printPoint() { System.out.print("[" + String.format("%.2f", x) + ", " + String.format("%.2f", y) + "]"); } } // end class Point   Circle code: public class Circle {     //declaring data members      protected double radius;     protected Point center;          //constructor     public Circle()     {         radius=0;         center=new Point();     }          //parameterized constructor     public Circle(Point p, double radius)     {         center=p;         this.radius=radius;     }          //getters and setters for radius      public double getRadius()     {         return radius;     }          public void setRadius(double radius)     {         this.radius=radius;     }          //getters and setters for center     public void setCenter(Point p)     {         center=p;     }          public Point getPoint()     {         return center;     }          //finding area      public double getArea()     {         return 3.14*radius*radius;     }          //finding circumference     public double getCircumference()     {         return 2*3.14*radius;     } }

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

Every cylinder has a base and height, where the base is a circle. Design the class Cylinder that can capture the properties of a cylinder and perform the usual operations on a cylinder. Derive this class from the class Circle (done through Problem 3.2). Please do the following:

  1. Some of the operations that can be performed on a cylinder are as follows: calculate and print the volume, calculate and print the surface area, set the height, set the radius of the base, and set the center of the base.
  2. Write a test program to test your program.

Note: Java programming. Please also send the test program so I can run it in dr java and learn. Use given code and design the class cylinder that can capture the properties of a cylinder and perform the usual operations on a cylinder.

Point code:

// class Point

public class Point
{
protected double x, y; // coordinates of the Point

//Default constructor
public Point()
{
setPoint( 0, 0 );
}

//Constructor with parameters
public Point(double xValue, double yValue )
{
setPoint(xValue, yValue );
}

// set x and y coordinates of Point
public void setPoint(double xValue, double yValue )
{
x = xValue;
y = yValue;
}

// get x coordinate
public double getX()
{
return x;
}

// get y coordinate
public double getY()
{
return y;
}

// convert point into String representation
public String toString()
{
return "[" + String.format("%.2f", x)
+ ", " + String.format("%.2f", y) + "]";
}

//Method to compare two points
public boolean equals(Point otherPoint)
{
return(x == otherPoint.x &&
y == otherPoint.y);
}

//Method to compare two points
public void makeCopy(Point otherPoint)
{
x = otherPoint.x;
y = otherPoint.y;
}

public Point getCopy()
{
Point temp = new Point();

temp.x = x;
temp.y = y;

return temp;
}

// print method
public void printPoint()
{
System.out.print("[" + String.format("%.2f", x)
+ ", " + String.format("%.2f", y) + "]");
}

} // end class Point

 

Circle code:

public class Circle
{
    //declaring data members 
    protected double radius;
    protected Point center;
    
    //constructor
    public Circle()
    {
        radius=0;
        center=new Point();
    }
    
    //parameterized constructor
    public Circle(Point p, double radius)
    {
        center=p;
        this.radius=radius;
    }
    
    //getters and setters for radius 
    public double getRadius()
    {
        return radius;
    }
    
    public void setRadius(double radius)
    {
        this.radius=radius;
    }
    
    //getters and setters for center
    public void setCenter(Point p)
    {
        center=p;
    }
    
    public Point getPoint()
    {
        return center;
    }
    
    //finding area 
    public double getArea()
    {
        return 3.14*radius*radius;
    }
    
    //finding circumference
    public double getCircumference()
    {
        return 2*3.14*radius;
    }
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Similar questions
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