Logic doesn't work in this method overloading example. : I'm sudying java from the Pluralsigh.com. Code below is written by me to follow the video lessons. The topic is method overloading. The code seem to not increment the passenger count as soon as I implement the hasCarryOnSpace method. I call this method inside the add1Passanger(int bags, int carryOns) method after the if statement. I also call it inside the add1Passenger(Passanger p, int carryOns) method. Please tell me what's wrong with my logic...


public class Flight {

	//fields
	public int passengers;
	private int seats = 150;
	private int checkedBags;
	private int maxCarryOns = checkedBags*2, totalCarryOns;
	private int freeCheckedBags;

	//getter/setters
		public int getSeats(){return 150;}
		public int getCheckedBags() {return this.checkedBags;}

		
	//constructors
	public Flight (){}	
	public Flight(int freeCheckedBags){
		this.freeCheckedBags=freeCheckedBags;}	
	public Flight(int freeCheckedBags, int checkedBags){
		this(freeCheckedBags); 
		this.checkedBags=checkedBags;}

	
	//methods	
	public void addPassengers(Passenger... list){
		if(hasSeats(list.length)){
			passengers += list.length;
			for(Passenger passanger: list){
				checkedBags += passanger.getCheckedBags();
			}
		}
		else tooMany();	
	}

	public void add1Passenger(){
		if(hasSeats())
			passengers +=1;
		else tooMany();
		return;
	}

	public void add1Passanger(int bags){
		if(hasSeats()){
		add1Passenger();
		this.checkedBags+=bags;
		}
	}

	public void add1Passenger(Passenger p){
		add1Passanger(p.getCheckedBags());
	}

	public void add1Passenger(int bags, int carryOns){
		if(hasSeats() && hasCarryOnSpace(carryOns)){
			add1Passanger(bags);
			totalCarryOns+=carryOns;
		}
	}

	public void add1Passenger(Passenger p, int carryOns){
		add1Passenger(p.getCheckedBags(), carryOns);
	}
	
	public boolean hasCarryOnSpace(int carryOns){
		return totalCarryOns+carryOns < maxCarryOns;
	}
	
	public boolean hasSeats(){
		return passengers < getSeats();
	}

	private boolean hasSeats(int count) {
	return passengers+count <= seats;
    }
	
	private void tooMany(){
		System.out.println("no more seats available");
	}
	
    //main method
	public static void main(String[] args ){
		Flight usAir = new Flight();
		//i have a separate Passenger class created w/ freeBags as first
        //parameter and checkedBags as the second in its constructors
		Passenger bob = new Passenger();
		Passenger jean = new Passenger(0, 1);		
		Passenger nick = new Passenger(0, 2);
		Passenger dan = new Passenger(2,2);

		usAir.addPassengers(bob, jean);
		usAir.add1Passenger(dan);
		usAir.add1Passenger();
		usAir.add1Passanger(2);
		//calls below don't increment the passenger count
		usAir.add1Passenger(nick, 2);
		usAir.add1Passenger(1, 1);
		System.out.println("usAir has " + usAir.passengers 
				+ " passengers " + "with " + usAir.getCheckedBags()+
				" checked bags,"+" "+usAir.freeCheckedBags
				+" free bags, and "+usAir.totalCarryOns+" carryOns on board");
	}
}