Hey guys I am trying to practice some OOP and I keep on getting this error stating "cannot find symbol"
Java Code:
public class Triangle{
public static void main(String[] args){
TriangleFeatures A = new TriangleFeatures(2.0);
//base.getBase(2.0);
System.out.print("The base of Triangle A is: " + base.getBase() + ".");
}
}
Java Code:
class TriangleFeatures{
private double base;
TriangleFeatures(){
base = 0;
}
TriangleFeatures(double newBase){
this.base = newBase;
}
public double getBase(){
return base;
}
public void setBase(double x){
this.base = base;
}
}
can someone help me? I receive the error when I try to print out the base of the triangle. (base.getBase())
No comments:
Post a Comment