Question seat reservation algorithm C#

mitko9670

New member
Joined
Feb 3, 2021
Messages
2
Programming Experience
Beginner
I'm working on bus ticket reservation system. I have a problem in the booking module.

Say we have bus a route starts from "A" to "D" via "B" & "C"

The bus starts from "A" then reach "B", then "C" and final destination is "D".

Assume some one is reserving seat no "1" for "B" to "C", this seat no should not be available for the person who is searching for a seat to travel from "A" to "D" or "B" to "D" but the same seat should be available for "A" to "B" or "C" to "D"

Example in Summary

Seat No 1 is Reserved for "B" to "C"

  • Seat No 1 should not be available for "A"-"D"
  • Seat No 1 should not be available for "B"-"D"
  • Seat No 1 should not be available for "B"-"C"
  • Seat No 1 should be available for "A" to "B"
  • Seat No 1 should be available for "C" to "D"
 
Here's the possible routes, the ones containing BC is not available, the others are:
x ABCD
v AB
x ABC
x BC
x BCD
v CD
 
Put the possible routes in an array of strings, use string.Contains method to check them for the reservation string.
 
I'm not sure that you understand what an algorithm actually is. It is a set of steps you can follow to get from particular inputs to particular outputs. An algorithm has nothing specifically to do with any particular programming language. The whole point is that the algorithm can be implemented any way you like. The way you should be tackling programming problems is to first consider what you would do if it were a purely manual process. That enables you to determine the steps involved and to write an algorithm. Implementing that algorithm in C# is the last step. So, how would you do this if it were purely manual, e.g. done on pen and paper? That's not programming - it's purely logic - so you don't need any programming experience to answer it. If you don't know what the steps are then you haven't considered the problem. Even if this were a programming problem, i.e. how to write C# code, it has nothing specific to do with Windows Forms so I am moving the thread.
 
I've been celebrating today. So lets see what I can manage to put together in this state. Given, I've just drank a half bottle of Jack Daniels.

I would however, like to see what you have tried to develop, and show what code you've come up with. As this will allow us all to better assist you.
 
In the last 20 minutes, here's what I came up with. Are you looking for something like that?

ODBEFAe.gif
 

Latest posts

Back
Top Bottom