Hi, I am trying to figure out a problem but i cant my mind is totally blocked. I have to make conditions for this:

When someone makes reservation it checks the availability of the table.

the time of a reservation should last 3 hrs.

Now i want a condition that checks the time of other reservation and if it is smaller than the other reservation time it checks if in 3 hours there are no reservations.

and if it is bigger it ccheckes that the reservation held before (+3hrs) does not clash with the current reservation.

I have my ideas confused. Help pls

How are you storing your reservations for a table?

If you keep track of them in a 24 element boolean array then you can just check if the three "hours" in the array are true/false depending on if there is or isn't a reservation on those times.

For example

//... inside your table?
bool reserveTable(int startTime) //if this returns false, there is a clash. as in there is already a reservation for the time requested.
    //this assumes that you've done any sort of conversion from the user input to a 24-hour format where 0=midnight and 23=11pm for startTime
    if (!_reservationList[startTime] && !_reservationList[startTime + 1] && !_reservationList[startTime + 2])
        _reservationList[startTime] = _reservationList[startTime + 1] = _reservationList[startTime + 2] = true;
        return true;
        return false;

This simply checks the three hour window you want to reserve and returns true/false if it was reserved successfully.