I'm getting the error "error: recursive constructor invocation", this seems to correlate with not having a constructor that is initialized with parameters, and just using the this(), I have all the constructor signatures different, so I'm not sure what the problem is. Am I somehow not using this() correctly?
public class passenger{
private int checkedBags;
private int freeBags;
private double bagsFee;
public int getCheckedBags(){
return this.checkedBags;
}
public void setCheckedBags(int checkedBags){
this.checkedBags=checkedBags;
}
public int getFreeBags(){
return this.freeBags;
}
public void setFreeBags(int freeBags){
this.freeBags= freeBags;
}
public double getBagsFee(){
return this.bagsFee;
}
public void setBagsFee(double bagsFee){
this.bagsFee=bagsFee;
}
//all the examples I looked up online seem to correlate with one constructor not being intitialized
passenger(int checkedBags, int freeBags, double bagsFee){//this is
this.checkedBags= checkedBags;
this.freeBags= freeBags;
this.bagsFee= bagsFee;
}
passenger(int freeBags){
this(freeBags);//giving error
}
passenger(double bagsFee){
this(bagsFee);//giving error
}
passenger(){
}
public static void main(String[] args){
passenger john= new passenger();
passenger kate= new passenger(2,1,100d);
System.out.println(john.getCheckedBags());
System.out.println(john.getFreeBags());
System.out.println(john.getBagsFee());
System.out.println(kate.getCheckedBags());
System.out.println(kate.getFreeBags());
System.out.println(kate.getBagsFee());
}
}