Bus Reservation Server
This program should implement a server that is able to do bookings for a bus service company. The server has to hold a database (free implementation) with all buses' routes. This database has to hold at least the following information for each route:
For instance:
Route 1:Initial City - Stopovers - Final Destination Rib. Preto S.Carlos, Araraq. Catanduva Bus1 6:00 7:00 7:30 8:30 Bus2 11:00 12:00 12:30 13:30 Bus3 15:00 16:00 16:30 17:30 Bus1: Seat Rib. Preto S.Carlos, Araraq. Catanduva 01 X--------Ocupied-------X 02 X-------Ocupied-----X 03 X---Ocupied---X X--Ocupied-X 04
The client should be able to execute at least the following commands:
list1 <Departure City> <Destination> : It shows the available buses and number of seats in each bus connecting the two destinations:
list1 RibPreto SCarlos Bus1 6:00 7:00 12 seats Bus2 11:00 12:00 4 seats Bus3 15:00 16:00 8 seats
list2 <Departure City> <Destination> <Bus>: It shows the available seats in a particular bus connecting the two destinations:
list2 RibPreto SCarlos Bus2 Bus2 2 34 35 40
get <Departure City> <Destination> <Bus> <seat>: It books a particular seat for a passenger (It can return OK or failure):
get RibPreto SCarlos Bus2 34 OK: RibPreto 11:00 SCarlos 12:00 Bus2 34
cancel <Departure City> <Destination> <Bus> <seat>: It cancels a particular seat for a passenger (It can return OK or failure):
cancel RibPreto SCarlos Bus2 34 OK: RibPreto 11:00 SCarlos 12:00 Bus2 34
The server should be able to book and to cancel slots. If a seat is booked between Rib. Preto and S. Carlos, it should be able to book the same seat between S. Carlos and Catanduva.
NOTE: The program must use shared memory and threads in its implementation (take care to protected shared memory areas with mutex and/or semaphores). The program does not need to keep information on files, it does not have to be persistent.