I've been doing some tutorial on inheritance abstract class, and I pass an array to a function for a calculation of total price. But then, when I tried to call the function in the main, it didn't work and I've got some error according the method call.
Here is my calculation code in subclasses :
public double calcPrice(String[] a, int[] qty, int num){
int i =0;
for(i=0;i<=num;i++) {
if (a[i]=="a")
price=24.90;
}
double tot=price+qty[i];
return tot;
}
This is my method call in the for loop. I don't know how to call the method as the error says "non-static method calcPrice() cannot be referenced from a static context"
for(int i=0;i<=num;i++) {
System.out.println("\t"+a[i]+"\t\t\t"+qty[i]+" "+calcPrice());
}