class - Java classTest error -


i wrote class , trying test it, , , error on class test says "cylindertest.java:9: getheight() in cylinder cannot applied (double)"

here code class:

public class cylinder private double radius; private double height; public final static double pi = 3.14159; // constructor public cylinder() {     radius = 0.0;{      height = 0.0; } // getraduis method public double getradius() {            return radius; } // getheight method public double getheight() {      return height; } // setradius method  public void setradius(double r) {     radius = r; } // setheight method public void setheight(double h) {     height = h; } // getsurfacearea public double getbasearea(double basearea) {     basearea = radius * radius * pi;     return basearea; } // getvolume public double getvolume(double basearea, double volume) {     volume = basearea * height;     return volume; } // print //system.out.println("the volume of cylinder " +volume); 

}

and here code classtest:

public class cylindertest {     public static void main(string[] args)     {         cylinder cylindera = new cylinder();         cylindera.getradius(3.5);         cylindera.getheight(4.5);         system.out.println(cylindera.getvolume());     } } 

the original cylinder class wrote compiles fine having trouble when try compile classtest. appreciated.

you're calling getter method when looks should calling setter method:

cylindera.setheight(4.5);  //        ^ 

if intend call getter method, call this:

double height = cylindera.getheight(); 

because getheight doesn't have parameters.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -