Hi
I have error in my code (Reservation.h). I try to search forum and many thing but always have error. Is there someone who can help me a debugg my program please.
The program should display the following menu:
Press 1 for wifi
Press 2 to offline
If the answer is 1, the program assigns a seat in a bus offline (1 to 40). Otherwise, it allocates a seat in a bus wifi (1 to 40). In addition, the program should display on the screen a travel document that indicates whether the passenger in a bus or a bus wifi offline and how many passengers there on the bus.
Try this, see if it runs correctly, and if you have any questions feel free to ask, I will be happy to help. Your biggest problem was just forgetting to capitalize the 'B' in Bus.
Reservation.h is ok now but the program does not work as I want.
The menu appears correctly but do not book a seat Assigns a bus.
It immediately wrote
When I press 1 the program writes: Bus is full offline
When I press 2 program writtes: Wifi Bus is full
I want:
If the answer is 1, the program Assigns a seat in a bus offline (1 to 40). Otherwise, it allocates a seat in a bus wifi (1 to 40). In addition, the program display on the screen shoulds a travel document That Indicates Whether the passenger in a bus or a bus wifi and offline How Many passengers on the bus there.
Your code will be much easier to read and understand - both for you, and for anyone else trying to read it - if you use consistent indentation. It will make it much easier to see at a glance which code is inside which method, and inside which class.
I can see why it's doing what it's doing. In the constructor for Bus, you initialise nbseat to 40, and nbSeatAllocated to 0. So when you call Reservation::reservedOffline(), which calls through to Bus::reservedSeat(), nbSeat < nbSeatAllocated is always false. The method will always return 0.