|
This sounds very interesting.
I will continue to learn what I am from the book, then I may be able to place this code into context.
Thank you, it seems much better than the standard Rand.next(0,35);
Regards,
Stephen
|
|
|
|
|
if you don't need the ball placement then i would recommend sticking with the simple random.next(), A true random number is not possible (at least generated electronically) but the random.next() is pretty good and any system deriving a random number from logic wrapped around a call to that method is at best going to be equally as good but, more likely, introduce bias (which the code i posted above most certainly does).
I posted that code more as a theoretical exercise in how one might simulate a (simplified) roulette wheel, for a system in which bias should be minimal (such as a gambling game in which real money is exchanging hands) it would be better to generate a random number through random.next() and then, having done this, calculate the animation of the ball (so that the ball itself is merely representing the already generated result and not playing a part in generating it)
Keep reading the book, but don't forget to get in there and get your hands dirty. Nothing teaches programming like attempting to program
|
|
|
|
|
Hi.
This is for fun, and not the real thing. It is going to be my first "real" project after the book. Although I would like it to be as "real" as possible.
I was actually thinking along the same lines.
1) Generate a random number 0-36
2) Animate the wheel, and somehow when the ball arrives near the generated number, make it "bounce a little" as though it was going to (random again) land on the number to the left or right before "faling" into place.
3) Use some kind of list/enum to look up the value and also get whether it is black or red (or green)
I have just started with the book now, and when I finish I am going to give this a real go.
Thank you for your advice and comments.
Kind Regards,
Stephen
|
|
|
|
|
Hi everyone,
Many off you know I ask a lot of questions, and although I am a complete beginner with c#, it is simply for the fact that I am impatient and want to get on with it, however, I now realise that I need to sit down with a good book.
Anyway, I have just purchased "Head First C#" 2nd edition.
I selected this book as some of the real-world projects appealed to me.
I would like to know if anyone has any experience with this book, and if I have made a good choice for a first book, and if I am likely to learn much in the way of windows development with c#?
Thank you,
p.s. LucPatton, if you are reading this, I am sure you will be happy (and relieved) that I finally got a book
|
|
|
|
|
Yes, it is really a very good book, especially for the beginners. Happy reading...
|
|
|
|
|
|
stephen.darling wrote: I now realise that I need to sit down with a good book.
Good decision
stephen.darling wrote: I have just purchased "Head First C#" 2nd edition.
That's being used in school 'ere; covers a lot, reads quite pleasantly.
stephen.darling wrote: if I have made a good choice for a first book
Yup, definitely worth the time
Bastard Programmer from Hell
|
|
|
|
|
Eddy Vluggen wrote: Good decision
Yes; I realise that now!
Eddy Vluggen wrote: That's being used in school 'ere; covers a lot, reads quite pleasantly.
Really? If it is being used in a school, must be OK then.
Eddy Vluggen wrote: Yup, definitely worth the time
Great. I will crack on and be back soon with my questions ha.
Thank you
|
|
|
|
|
Hi Stephen,
fyi, I found Jesse Liberty's books on C# from O'Reilly exceptionally good. And, currently I am studying Jon Skeet's 'C# in Depth," (Manning Press) which I regard as kind of the "Ph.D." level book on the subject (and one I suspect will take me years to really 'grok').
For Windows Forms, in addition to Liberty's book, I found Matthew MacDonald's books from APress excellent.
best, Bill
"In the River of Delights, Panic has not failed me." Jorge Luis Borges
|
|
|
|
|
Hello CP,
I'm currently messing around to build a plugin system and want to use subfolders.
After a bit of searching I found that adding a <probing privatepath=""/> element to app.config allowed subfolder usage.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="lib" />
</assemblyBinding>
</runtime>
My only objection to this is that it is yet another file (one the user can edit :s) , my question is:
Can I merge this configuration file with the exe or is there another way to do this?
It would be preferable to put this in the manifest or something.
The first rule of CListCtrl is you do not talk about CListCtrl - kornman
modified on Sunday, August 28, 2011 11:13 AM
|
|
|
|
|
You can modify the configuration during runtime.
However whether it uses it to pick up assemblies is a different point.
Myself I don't see the utility. To create a plugin system you need to load from somewhere dynamically. That is the initial path. There isn't much point in having the framework (the loader) to provide options that require the plugin to follow a loading scheme that for most plugins shouldn't matter. So if the primary assembly is in director 'Bdir' then the plugin will probably have dependent assemblies in that directory and no other. And the standard assembly load mechanism will find those because the primary assembly was loaded from that.
But further note that the point of configuration is specifically so that users can modify it. And a plugin system is pretty much by it very nature suggesting that users are going to be responsible for it. So either the system is simple to begin with or one must assume that the users are intelligent enough to deal with it.
|
|
|
|
|
I am writing a C#.net windows desktop/windows form application in 2008 or 2010. When the application basically starts in program.cs in the main method., I am going to check to see if a user has access to this new desktop at all. I am also going to check to see what parts of the application the user has access to by looking at the active directory. When a user clicks on various tabs in the application there is going to be read only or read-write access. When there is read-write access, I going going to display the extra buttons only to those users only.
I have the following questions to ask:
1. Would you put this kind of logic in program.cs? If not, where would you suggest I put this logic and can you point me to a code reference I can use?
2. For the parts of the application where a user clicks on a tab that have either read-only or read-write access:
a. I was thinking of of storing the active directory groups that user has access to in global variables. However this is generally not a good idea due to not following good object oriented design princicples. if you were going to keep these values stored in variables, how would you accomplish this task?
2. Another option would be to do the same kind of basic ldap lookup everytime a user clicks on that tab on the desktop. How would you accomplish this option?
3. Do you have other options to suggest? if so, what are they? Can you explain your alternative option to me and/or point me to a url that will explain how you accomplish your optiuon?
|
|
|
|
|
dcof wrote: by looking at the active directory
What if there is no Active Directory?
dcof wrote: Would you put this kind of logic in program.cs?
No.
dcof wrote: where would you suggest
In a class that is designed for it.
dcof wrote: how would you accomplish this task
In a class that is designed for it.
dcof wrote: basic ldap lookup everytime a user clicks on that tab
Is that data likely to change?
dcof wrote: alternative option
Maybe investigate what's inside a Windows Principal[^]?
|
|
|
|
|
In reposne to your answers,I have the following additioanl questions:
1. Would you put this kind of logic in program.cs? No.
Why would you not put the code in this section? If the application is going to shutdown right away, why not close the app right away?
2. Would you have the program.cs call the code for LDAP right away?
|
|
|
|
|
Very very little goes into the main method; unless it's a simply command-line utility.
|
|
|
|
|
Your response, 'Very very little goes into the main method; unless it's a simply command-line utility.'.
Is this a requirement of microsoft? Is this a best practices standard?
If this is a requirement, are there any other parts of the application I should not put extra code into it?
|
|
|
|
|
dcof wrote: 1. Would you put this kind of logic in program.cs? If not, where would you suggest I put this logic and can you point me to a code reference I can use?
At some point you are going to have GUI components (classes) Which will NOT be part of program.cs (And with enough complexity the GUI components might be in their own assembly.
You are also going to need at least one class that does nothing but the Active Directory interaction. The GUI components call that class. That class then retrieves the necessary information.
The GUI components are then used in program.cs. In addition program.cs will use the above class to do the initial start up check. Presumably you are already planning on telling the users that they failed the initial Active Directory check.
dcof wrote: .<layer> Another option would be to do the same kind of basic ldap lookup everytime a user clicks on that tab on the desktop. How would you accomplish this option?
I would investigate the requirement that lead to this in the first place. Authentication and Authorization is best done with roles not users. A user belongs to a role. The role controls access. I would probably implement it in a database. I would probably cache it with a short expiration time.
|
|
|
|
|
The code I am going to setup is to check for the roles the user has access. If the user not does have does not access to anything by looking at the active directory roles they are assigned to, they will be taken out of the application with an error message.
|
|
|
|
|
Hi, I'd like to make a program that talking(reply) to user
example
User: How do you do!
Computer : How do you do!
User: I'm tired
Computer : Have a rest !
& soon ,,,,,, thanks
|
|
|
|
|
You're not going to be able to (realistically speaking) make a true talking program. Much work is still being done of that field to make real talking computers.
However, you can have a go at something that looks like it. Start, for instance, by creating a 'database' of Question/Response pairs, where if the user asks Question, you read the corresponding Response from the database and output it.
Then you can work on string matching, such that minor changes in the typed question still match to a predefined question in your database, e.g. "What are you doing?" and "What you doing?" should probably be considered the same question.
You can then continue by defining keywords, that when seen in a question trigger a certain response. For instance, in your example the user says "I'm tired". If that specific question isn't in your database, but the keyword 'tired' is, then you can have a guess from seeing this keyword that the user is tired, and you say something like "Have a rest". Of course, the user could have asked "Are you tired?", in which case "Have a rest" wasn't the right response.
You could add a check for if the user ended with a question mark (?), in which case you can assume that whatever typed was a question.
At any rate, I'd say have at it, try experimenting, combining things. Come up with ways to understand the users intentions as well as possible. It's quite a fun thing to try, and also quite challenging.
|
|
|
|
|
There should be some ELIZA[^]-like open source applications out there, and some MSN-chatbots of course
Bastard Programmer from Hell
|
|
|
|
|
Eliza is open source, if you don't mind Lisp.
/ravi
|
|
|
|
|
If she talks with a Lisp, that might be a problem for the OP...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
special , thanks to all who answered the question
& in your opinions how to solve the problem of "lisp"????
thanks
|
|
|
|
|
I have a reprint of Weizenbaum's original paper published in Jan 1966 and now in the public domain. I can email it to you if you like.
/ravi
|
|
|
|