Question: please solve using java use can use there classes from the rolling code if necessary class Point{ // point class to hold circle centre protected


please solve using java use can use there classes from the rolling code if necessary
class Point{ // point class to hold circle centre protected double x; // protected member protected double y; public Point() { // default constructor x=0; y=0; } public Point(double x, double y) { // parametrized constructor this.x = x; this.y = y; } public void setPoint(double x,double y){ // set the centre this.x = x; this.y = y; } public double getX() { return x; } // getters public double getY() { // getter of y return y; } @Override public String toString() { // toString method overrided return "Point: " + "x: " + x + ", y: " + y; } public boolean equals(Point point) { // compares two centres return Double.compare(point.getX(), getX()) == 0 && Double.compare(point.getY(), getY()) == 0; } public void makeCopy(Point x){ // make a copy of the point this.x = x.getX(); this.y = x.getY(); } public Point getCopy(){ // return that copy return this; } public void printPoint(){ // print the point coordinate System.out.printf("(%.2f,%.2f)%n",x,y); } } class Circle extends Point{ // circle class inheriting point class protected double radius; // double radius public Circle() { // default constructor radius=0.0; x=0.0; y=0.0; } public Circle(double radius,double x,double y) { this.radius=radius; // parametrized constructor this.x=x; this.y=y; } public void setCircle(double radius,double x,double y){ this.radius = radius; // set radius and point this.x = x; this.y = y; } public void setRadius(double radius){ // set radius of circle this.radius = radius; } public double getRadius() { // getter of radius return radius; } @Override public String toString() { // tostring method return "Radius: " + radius+" Point: " + "x: " + x + ", y: " + y; } public boolean equals(Circle circle) { // compare two circles return Double.compare(circle.getRadius(), getRadius()) == 0; } public void makeCopy(Circle x){ // make copy of the circle this.radius = x.getRadius(); this.x=x.getX(); this.y=x.getY(); } public Circle getCopy(){ return this; } public void printCircle(){ // print circle System.out.printf("%.2f, (%.2f,%.2f)",radius,x,y); } public void area() { // function to print the area of circle double a=3.14*radius*radius; System.out.println(); System.out.println("Area is "+a); } public void circumference() // print circumference of circle { double c=2*3.14*radius; System.out.println("Circumgerence is "+c); } } public class Main { public static void main(String[] args){ Circle myCircle = new Circle(5.00,4.00,7.23); // circle class object Circle yourCircle = new Circle(0.00,0.00,0.00); myCircle.printCircle(); // print myCircle yourCircle.printCircle(); // print YourCircle yourCircle.setCircle(5.00,45.00,82.20); // setCircle yourCircle.area(); // display area of your circle yourCircle.circumference(); System.out.println("Are the circles equal? "+yourCircle.equals(myCircle)); myCircle.setPoint(6.50,8.75); // setCentre of circle myCircle.setRadius(13.0); // set radius myCircle.setCircle(6.50,8.75,13.00); yourCircle.makeCopy(myCircle); // amke a copy of circle } }3. 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 that we already designed in #2. 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. The class Cylinder should contain the following methods and data member: protected member height default constructor constructor with parameters setCylinder(x) getHeight() setHeight(x) toString() equals(x) makeCopy(x) getCopy() printcylinder() surfaceAreal) volumel) The output should show the following: Initialize myCylinder to (5.00, 4.00,7.23,2.30) Initialize yourCylinder to (Q.00, 0.00, 0.00, 0.00) Set your Cylinder to (5.00, 45.00, 82.20, 2.80) Determine the surface area of your Cylinder: ??? Determine the volume of yourCylinder: ??? Determine if the 2 cylinders are equal or not Enter the center with (5.0, 8.75), radius with 52.0, height with 12.5 Set myCylinder to (5.00, 8.75, 52.00, 12.50) Copy myCylinder into yourCylinder and print yourCylinder Print your program to test the class Cylinder Paste the output after the program Print the Cylinder, Circle, AND Point classes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
