Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Random_name_generator_BASIC
- {
- public partial class RNGB : Form
- {
- public RNGB()
- {
- InitializeComponent();
- }
- Random R = new Random();
- string RandomLetter = "abcdefghihjlmnopqrstuvwxyz";
- string RandomVovel = "aeiou";
- string RandomConsonant = "bcdfghjklmnpqrstvxyz";
- int Vovel; // How many letters have been vovels after each other?
- int Consonant; // Same as above but with consonants
- bool First = true;
- bool IsVovel(char Info) // Adds +1 to vovel if it is a vovel, or +1 to con.. if it is a con..
- {
- for (int I = 5; I >= 0; I--)
- {
- if (Info == RandomVovel[I])
- {
- return true;
- }
- }
- return false;
- }
- char Letter() // Generate a raondom letter with some set logic
- {
- string LetterType = "";
- char Letter = "A"[0];
- if (First == true && CbControl.Checked == true && TbLetter.TextLength == 1)
- {
- try
- {
- Letter = TbLetter.Text[0];
- }
- catch (FormatException)
- {
- Letter = "A"[0];
- }
- }
- else
- {
- if (First == true)
- {
- LetterType = RandomLetter;
- }
- else // code for making max two consonants or vovels appearing after each other.
- {
- int I = R.Next(1, 100);
- if (Consonant == 2)
- LetterType = RandomVovel;
- else if (Vovel == 2)
- LetterType = RandomConsonant;
- else if (Vovel == 1)
- {
- if (I > 70) // Makes sure there are a 70% chance of there being only one vovel
- LetterType = RandomVovel;
- else
- LetterType = RandomConsonant;
- }
- else
- {
- if (I > 70) // Makes sure there are a 70% chance of there being only one consonant
- LetterType = RandomConsonant;
- else
- LetterType = RandomVovel;
- }
- }
- Letter = LetterType[R.Next(0, LetterType.Length)]; // Set a letter to a random part of the string LetterType
- }
- bool V = IsVovel(Letter); // Checks if Letter is a 'vovel' or notvovel
- if (V)
- {
- Vovel++;
- Consonant = 0;
- }
- else
- {
- Consonant++;
- Vovel = 0;
- }
- if (First)
- {
- First = false;
- return char.ToUpper(Letter);
- }
- else
- return Letter;
- }
- private void BActivate_Click(object sender, EventArgs e)
- {
- string Text = "";
- lblText.Text = "";
- int lenght = 3;
- if (CbLenght.Checked)
- lenght = (int)NUDLenght.Value;
- for (int I = (int)NumUD.Value; I > 0; I-- )
- {
- if (!CbLenght.Checked)
- lenght = R.Next(3, 8);
- for (int Wordlenght = lenght; Wordlenght > 0; Wordlenght--)
- {
- Text += Letter();
- }
- lblText.Text += Text + "\n";
- Text = "";
- First = true;
- }
- }
- private void CbControl_CheckedChanged(object sender, EventArgs e)
- {
- if (CbControl.Checked)
- TbLetter.Visible = true;
- else
- TbLetter.Visible = false;
- }
- private void CbLenght_CheckedChanged(object sender, EventArgs e)
- {
- if (CbLenght.Checked)
- NUDLenght.Visible = true;
- else
- NUDLenght.Visible = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement