Anda di halaman 1dari 3

/** * Write a description of class Cylinder here.

* * @author (your name) * @version (a version number or a date) */ public class Cylinder { // instance variables - replace the example below with your own private int radius; private double height; private String color; /** * Constructor for objects of class Cylinder */ public Cylinder() { // initialise instance variables radius=5; height=10; color="red";

} public Cylinder(int aRadius, double aHeight,String aColor)

{ radius=aRadius; height=aHeight; color=aColor; } public double getHeight() { return height; } public int getRadius() { return radius; } public String getColor() { return color; } public double getVolume() { return height*radius*radius*Math.PI; } public double getSurfaceArea() { return (2.0*radius*Math.PI*height)+(2.0*radius*Math.PI*radius);

} public void doubleHeight() { height=height*2; } public void changeColor(String myCol) { color=myCol; } public void doubleRadius() { radius=radius*2; }

/** * An example of a method - replace this comment with your own * * @param y a sample parameter for a method * @return */ the sum of x and y

Anda mungkin juga menyukai