- .Net-based Wacky Fun Random Numbar Generator
- 15 Oct 2010 09:54:59 pm
- Last edited by qazz42 on 15 Oct 2010 09:57:03 pm; edited 1 time in total
» Forum
> Your Projects
Don't call the topic title WFRNG.net unless you made a website called "wfrng.net". .Net or .NET are the proper titles of the Microsoft library/environment/IDE thing
qazz42 wrote:
yeah, I tihnk that came up in omni too >.<
Dammit, can anyone make a post on Cemetech anymore without mentioning rival sites at least three times per post?
Good job on this, though, qazz; do you have any screenshots for our enjoyment?
Well at least there's one small good thing about this clone: it's not 200 KB large like the other Windows WFRNG clone on ticalc.org.
qazz42 wrote:
D:
Noo! Oh well, suxs then :/
ok fine... a MessageBox.Show appears with nick's ticalc pass
Fascinating that you didn't decide to just display it in the console window like the rest of the text; I guess you wanted to test out everything you've learned thus far? Noo! Oh well, suxs then :/
ok fine... a MessageBox.Show appears with nick's ticalc pass
Nah, I just thought that the wonderful prize shouldnt be reduced to plain text, no, it gets the special treat of being in a MessageBox
Good work!
You should only create a single Random instance and use that throughout your program (that is, move Random myRandom = new Random(); outside the for ( ;; ) loop). You'll end up with the same sequence of random numbers every time; a typical way to avoid this is to seed the random number generator with a different value each time the program runs (one easy way is to use a truncated form of the current date and time, new Random((int)DateTime.Now.Ticks)).
Of course, this doesn't matter if you're only using a single random value (and changing every time you guess) but it's useful if you're aiming for a decent distribution of random numbers.
Your code throws an unhandled exception if you don't enter a valid number (e.g. "goat"). Consider using int.TryParse() instead, which will return true if value could be parsed and false otherwise.
Code:
I've never seen this pattern before:
Code:
Where did you pick that up?
You should only create a single Random instance and use that throughout your program (that is, move Random myRandom = new Random(); outside the for ( ;; ) loop). You'll end up with the same sequence of random numbers every time; a typical way to avoid this is to seed the random number generator with a different value each time the program runs (one easy way is to use a truncated form of the current date and time, new Random((int)DateTime.Now.Ticks)).
Of course, this doesn't matter if you're only using a single random value (and changing every time you guess) but it's useful if you're aiming for a decent distribution of random numbers.
Your code throws an unhandled exception if you don't enter a valid number (e.g. "goat"). Consider using int.TryParse() instead, which will return true if value could be parsed and false otherwise.
Code:
int guess;
do {
Console.Write("A=? ");
} while (!int.TryParse(Console.ReadLine(), out guess));
I've never seen this pattern before:
Code:
if (condition) {
// do something
} else ;
Where did you pick that up?
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
» Go to Registration page
» Go to Registration page
» Goto page 1, 2 Next
» View previous topic :: View next topic
» View previous topic :: View next topic
Page 1 of 2
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Advertisement