I have an abstract class A
and class B
extends from it.I made those variables private and its fine.
public abstract class A {
private String name;
private String location;
public A(String name,String location) {
this.name = name;
this.location = location;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLocation() {
return location;
}
Then I want to write the class B.
public class B extends A{
private int fee;
private int goals; // something unique to class B
I don't understand how to write a constructor for class B to access it's private variables. I wrote something like this and its wrong.
B(int fee, int goals){
this.fee= fee;
this.goals=goals;
}
Can u help me to solve this with a short explanation.