You've tried to call a method on an Object that does not support that method most likely.
Would you, please, mind checking the code?
class TwoDShape{
private double width;
private double height;
double getWidth(){return width;}
double getHeight(){return height;}
void setWidth(double w){width=w;}
void setHeight(double h){height=h;}
void showDim(){
System.out.println("Width and height are "+width+" and "+height);
}
}
class Triangle extends TwoDShape{
private String style;
Triangle(String s, double w, double h){
setWidth(w);
setHeight(h);
style=s;
}
double area(){
return getWidth()*getHeight()/2;
}
void showStyle(){
System.out.println("Triangle is "+style);
}
}
class Shapes{
public static void main(String args[]){
Triangle t1=new Triangle("isosceles", 4.0, 4.0);
Triangle t2=new Triangle ("right", 8.0, 12.0);
System.out.println("Info for t1: ");
t1.showStyle();
t2.showDim();
System.out.println("Area is "+t1.area());
System.out.println();
System.out.println("Info for t2: ");
t2.showStyle();
t1.showDim();
System.out.println("Area is "+ t2.area());
}
}