package experiment6;
import java.util.Scanner;
public class AccessPointCircleCylinder
{
public static void main(String agrs[])
{
Scanner input1 = new Scanner(System.in);
Cylinder Cy = new Cylinder(0,0,5,10);
System.out.printf("this Cylinder's base_circle is at (%d,%d)",Cy.getX(),Cy.getY());
System.out.println("this Cylinder's radius is"+Cy.getRadius());
System.out.println("this Cylinder's height is"+Cy.getHeight());
System.out.println("this Cylinder's Area is"+Cy.getArea());
System.out.println("Do you want change this Cylinder(yes/no)?");
String ans = input1.nextLine();
if(ans.equals("yes"))
{
System.out.print("Please input x,y:");
int x = input1.nextInt();
int y = input1.nextInt();
Cy.setX(x);
Cy.setY(y);
System.out.print("Please input radius,height:");
double radius = input1.nextDouble();
double height = input1.nextDouble();
Cy.setRadius(radius);
Cy.setHeight(height);
String str = Cy.toString();
System.out.println(str);
}
}
}
class Point
{
private int x,y;
Scanner input = new Scanner(System.in);
Point()
{
this(0,0);
}
Point(int xValue,int yValue)
{
this.x = xValue;
this.y = yValue;
}
public String toString()
{
return "The Point is"+ "(" + this.x + "," + this.y + ")";
}
public void setX(int x)
{
this.x = x;
}
public void setY(int y)
{
this.y = y;
}
public int getX()
{
return this.x;
}
public int getY()
{
return this.y;
}
}
class Circle extends Point
{
private double radius;
Circle()
{
this(0,0,1);
}
Circle(int xValue,int yValue,double radiusValue)
{
super(xValue,yValue);
this.radius = radiusValue;
}
public String toString()
{
return "The Circle is At"+ "(" + super.getX() + "," + super.getY() + ")" + "," +""
+ "radius is" + this.radius;
}
public void setRadius(double radius)
{
this.radius = radius;
}
public double getRadius()
{
return this.radius;
}
public double getDiameter()
{
return this.radius*2;
}
public double getCicumference()
{
return 2*this.radius*Math.PI;
}
public double getArea()
{
return Math.PI*this.radius*this.radius;
}
}
class Cylinder extends Circle
{
private double height;
Cylinder()
{
this(0,0,1.0,1.0);
}
Cylinder(int xValue,int yValue,double radiusValue,double heightValue)
{
super(xValue,yValue,radiusValue);
this.height = heightValue;
}
public String toString()
{
return "The Cylinder's baseCirlce At"+ "(" + super.getX() + "," + super.getY() + ")" + "," +""
+ "radius is" + super.getRadius()+","+"the Height is" + this.height;
}
public void setHeight(double height)
{
this.height = height;
}
public double getHeight()
{
return this.height;
}
public double getArea()
{
double S1 = 2*super.getArea();
double S2 = super.getCicumference()*this.height;
return S1+S2;
}
}