#the program includes: random number generation + input from player + bigger/smaller comparisons between numbers +
Explore tagged Tumblr posts
Text
Spent like four hours this morning creating a "guess the random number" game from scratch in C#.
It argued with me basically the entire way (this is the first program I've really created, so not very surprising), but the worst part was trying to track down a way to get a "random number", because everything I looked into either didn't work or did something different.
Finally managed to modify one idea and create a method (1 random number, between 1-100), which I'm recording here for future (emergency) reference:
class MyClass { public int GenerateRandom () { Random randomNumber = new Random(); for (int ctr = 0; ctr <= 0; ctr++); return randomNumber.Next(101); } }
Is it the best way? No idea. But it's the only way that worked, and it works pretty okay? So, I'm pretty happy with it.
#personal stuff#school#also. this class that's started? gives me the feeling that it's a ''self-study'' type of class. aka ''we don't teach you fuck all''.#that might change. but that was my motivation for deciding to create ''something complicated'' in code.#just as a sort of self-reference of proving to myself that it's possible.#the program includes: random number generation + input from player + bigger/smaller comparisons between numbers +#debugging from player writing ''hello'' instead of numbers + victory-condition + a score for how many times you guessed +#a way to restart the game after winning (without having to restart the entire program) + a tiny bit of ascii-art#i feel like i'm pretty proud of it? all told? it definitely works the way i want it to. and i'm pretty happy with that.
1 note
·
View note