Created
August 6, 2015 18:10
-
-
Save money4honey/5a6eec31193c4779066d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace myClasses | |
{ | |
public class RandomMaster | |
{ | |
static Random random = new Random(); | |
static string[] numbers = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}; | |
static string[] alphabet = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" }; | |
public static bool randomBool(int chance, int max) | |
{ | |
int rNum = random.Next(max); | |
if (rNum <= chance) return true; | |
else return false; | |
} | |
public static string randomString(int length) { | |
string randomString = ""; | |
for (int i = 0; i < length; i++ ) { | |
if (randomBool(50, 100)) { | |
if (randomBool(50, 100)) { randomString += alphabet[random.Next(alphabet.Length)]; } | |
else { randomString += alphabet[random.Next(alphabet.Length)].ToUpper(); } | |
} | |
else { | |
randomString += numbers[random.Next(numbers.Length)]; | |
} | |
} | |
return randomString; | |
} | |
public static string randomStringLetters(int length) | |
{ | |
string randomString = ""; | |
for (int i = 0; i < length; i++) | |
{ | |
if (randomBool(50, 100)) | |
{ | |
if (randomBool(50, 100)) { randomString += alphabet[random.Next(alphabet.Length)]; } | |
else { randomString += alphabet[random.Next(alphabet.Length)].ToUpper(); } | |
} | |
} | |
return randomString; | |
} | |
public static string randomStringNumbers(int length) | |
{ | |
string randomString = ""; | |
for (int i = 0; i < length; i++) | |
{ | |
randomString += numbers[random.Next(numbers.Length)]; | |
} | |
return randomString; | |
} | |
public static int randomRange(int min, int max) { | |
return random.Next(min, max); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment