Hey everyone,
So that’s how my code looks like so far:
- Arrays
string[] passwordsLevelOne = { "zuckerberg", "instagram", "facebook", "social", "messenger" };
string[] passwordsLevelTwo = { "squareenix", "ubisoft", "activision", "naughtydog", "bungie" };
string[] passwordsLevelThree = { "stock", "currency", "deflation", "inflation", "crash" };
string[] passwordsHintOne = { "zurgcekber", "inasmtgra", "bocaefok", "olcisa", "meersengs" };
string[] passwordsHintTwo = { "sexquearni", "sutbifo", "acitvisoni", "nughatygod", "nubige" };
string[] passwordsHintThree = { "skotc", "crurynce", "dietflaon", "anfliotin", "schar" };
- Void RunMainMenu (string input)
else if (input == "1")
{
level = 1;
System.Random rdm = new System.Random(); // create a random
int pass = rdm.Next(5); // password will be randomly chosen in the array
password = passwordsLevelOne[pass]; // password is one and only one of the array
StartGame();
Terminal.WriteLine(passwordsHintOne[pass]); // hint is chosen accordingly to the password chosen randomly
}
else if (input == "2")
{
level = 2;
System.Random rdm = new System.Random();
int pass = rdm.Next(5);
password = passwordsLevelTwo[pass];
StartGame();
Terminal.WriteLine(passwordsHintTwo[pass]);
}
else if (input == "3")
{
level = 3;
System.Random rdm = new System.Random();
int pass = rdm.Next(5);
password = passwordsLevelThree[pass];
StartGame();
Terminal.WriteLine(passwordsHintThree[pass]);
}
- Help
This is the code I wrote to select the password and its hint randomly:
string[] passwordsLevelOne = {enter array here}; // {text1, text2, text3}
string[] passwordsHintOne = {enter array here}; // {t1, t2, t3}
// passwordsHintOne array must be in the same order than passwordsLevelOne array
else if (input == "1")
{
level = 1;
System.Random rdm = new System.Random(); // create a random
int pass = rdm.Next(enter the # of array); // password will be randomly chosen in the array
password = passwordsLevelOne[pass]; // password is one and only one of the array
StartGame();
Terminal.WriteLine(passwordsHintOne[pass]); // hint is chosen accordingly to the password chosen randomly
}
Hope this might help some of you and like always have a nice day