Hi guys so it's been a long day and I can't vent how angry I am
I love programming and I want to be the best programmer I can be and I have been putting countless hours in but it's things like this that makes me want to throw my laptop against a wall,because I am looking at the logic and I can't see how the logic is incorrect
when I call bookSeat,it just keeps printing seat not found
but how?????????
the seat clearly is found I have a map of seats which are properly sorted and initalised inside a map called seats
so when i = 2 and j = 'B' the if statement SHOULD execute and return true but instead it skips it and says seat not found wtf :s
bool bookSeat(int row,char letter,int lastRow,int lastLetter){
for(int i = 1; i < lastRow; i++){
for(char j = 'A'; j <= lastLetter; j++){
if(seats[Seat(i,j)].number == row && seats[Seat(i,j)].letter == letter){
cout << "seat found,do you want to book this seat press one for yes 2 for no" << endl;
int choice;
cin >> choice;
if(choice == 1){
seats[Seat(i,j)].taken = true;
returntrue;
}
}
}
}
cout << "seat not found " << endl;
returnfalse;
}
};
int main()
{
Airline Delta("Delta",101);
Delta.addSeats(50,'F');
Delta.bookSeat(2,'B',50,'F');
Delta.printSeats(50,'F');
}
Sorry I am not thinking straight have not eaten in hours and I realised that I should have used the size of the rows and last letter because the loop only went as far as 2 and letter B
Anyway I'm sorry for so many posts,these small things really drive me crazy sometimes
but thanks for sticking with me you guys on here mean a lot to me and have helped me so much.
I just find that I'm progressing so slowly =(,even though I put a lot of time into it between reading books,buying courses,browsing forums,and ofcourse writing small programs