|
Or have a Dictionary<char,Hashset<int>>
if ( dic [ row ].Contains [ number ] ) ...
|
|
|
|
|
Technically speaking, what your asking about is an algorithm. If you think about it purely analytically, you basically have these rules (I assume, I could have interperated your question incorrectly):
Available Rows: A - P
Available Seats: 1 - 18
Rule: Row between A and H, Seat geater than 15 = invalid
Rule: One assignment per Row/Seat combination
If your creating a booking system, the ultimate result of a booking is that you track which row/seat is assigned somewhere (in my example, a dictionary mapping a key(the row) to a list of ints (the seats):
class TheaterBooking
{
const char MAX_ROW = 'P';
const int MAX_SEAT = 18;
IDictionary<char,IList<int>> m_bookedSeats;
public TheaterBooking()
{
m_bookedSeats = new Dictionary<char,IList<int>>();
}
public bool IsValidNewBooking(char row, int seat)
{
if (row > MAX_ROW) throw new ArgumentException("Invalid row specified.", row);
if (seat > MAX_SEAT) throw new ArgumentException("Invalid seat number specified.", seat);
if (!IsValidSeat(row, seat))
return false;
if (IsAlreadyBooked(row, seat))
return false;
return true;
}
private bool IsValidSeat(char row, int seat)
{
if (row <= 'H' && seat > 15)
return false;
return true;
}
private bool IsAlreadyBooked(char row, int seat)
{
IList<int> filledSeats;
if (m_bookedSeats.TryGetValue(row, out filledSeats))
{
if (filledSeats.Contains(seat))
return false;
}
return true;
}
}
modified on Tuesday, January 13, 2009 8:44 PM
|
|
|
|
|
I added the code that you kindly sent to me to my project. But How dose it no witch seats are booked. I guess there must be some code like DictionaryName.Add (Var1,Var2 ); But Some how you need to declare the Keys and Ints. Were Var 1 is the key and Var 2 is Ints. Can you help?
|
|
|
|
|
The rest of the application is up to you. You would probably need to add a new method called BookSeat(char row, int seat) that first checks if the seat is valid, and if it is, adds a booking. The algorithm for that you have to figure out...as a programmer, thats your job. You have a huge head start because of what I gave you...learn from it, be creative, and finish the code on your own.
|
|
|
|
|
I need to start a C# .Net application (actually a windows form app) when Internet Explorer received a specific file, and that application needs to read the file content. In other words, IE receives a file containing data with an extension of .vdl and I set up .vdl file association to open my application readvdl.exe.How does my application read the content of the file received and passed on by Internet Explorer?
|
|
|
|
|
FileStream with path passed in string[] args I would imagine.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thank you, I know it was a simple thing but I didn't really know how it worked.
|
|
|
|
|
Hi,
I'm uasing "Shared Add-in Support Update for Microsoft .Net Framework 2.0 KB908002" as pre-requesites to load some Office plug-ins. I want to know whether this plug-in has been already installed or not? So far i couldnt find proper registry entry also.. Can some one tell me?
Thanks.
|
|
|
|
|
How does C# comes into play? You want to write a code for it?
The word "politics" describes the process so well: "Poli" in Latin meaning "many" and "tics" meaning "bloodsucking creatures."
जय हिंद
|
|
|
|
|
I have written the form in C# and I needed to know how to read the file sent via IE. Dave answered my question - IE sends you the temp file path as an arg and I can read it from there.
|
|
|
|
|
I seriously think that he wants to write a C# code to detect plug-ins in the windows registry, look bro, thts simple, do u know how to use google..........start from scratch and someone will help u out if u r struck.........we dont provide ready made solutions.........do ur homework first.......
|
|
|
|
|
Not at all, bro. I do know how to use google, bro. I used google extensively, bro, when searching for this, bro. I guess, bro I need to work on my search skills, bro. And I wasn't asking for ready made solutions. Read Dave's post above, that's all I needed. Yeah I know, simple huh bro? Cheers and thanks to Dave.
|
|
|
|
|
Hi guys!
Im trying to detect when a user "kills" my c# app using windows task
manager(so i can prevent it), i've tried with the form events _closing and _closed managing but it won't satisfy me
any one got any idea?
tancs
|
|
|
|
|
Yeah, you can try giving up, quitting or obtaining common sense.
|
|
|
|
|
what do u mean? what are those programs working like some of antiviruses that doesn't allow users to kill them from taskmanager?
|
|
|
|
|
Their called services
only two letters away from being an asset
|
|
|
|
|
so there is a solution, but if u know where should i start?
|
|
|
|
|
They never researched how to "share" keyboards and mouses in their "office"
Stop trying, you lose.
|
|
|
|
|
Those are all utilities that come with Windows. I think they're in the GetAFuckinClue folder.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Watch the language, please. Inappropriate and unhelpful.
cheers,
Chris Maunder
CodeProject.com : C++ MVP
|
|
|
|
|
Did someone rat me out, or do you check all of my posts as a matter of course?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
37% of our overall processing power is devoted to tracking everything you do.
cheers,
Chris Maunder
CodeProject.com : C++ MVP
|
|
|
|
|
I thought it was more than that.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Only 37%, seems low doesn't it?
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
They've probably got an 8-core system watching all of the forums (except the VB forums of course), and a custom event is triggered whenever I write a message, and it continues to be sent until someone looks at the message in question. Sometimes, just to screw with them, I write a lot of single-word messages just hoping to bring their event manager to its knees.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|