This program needs to randomly create first and middle names for boys and girls (5 for each in a list box) each time the boys button or girls button is pressed. Right now the program is riddled with syntax errors, mostly for there not being arguments given to meet the parameters in the methods. These exact parameters are required for the assignment, I've tried putting arguments for them in places that don't end up changing anything. Also, how can I assign a random to the index of the arrays used in this?
public partial class Form1 : Form
{
private string[] boys = new string[20];
private string[] girls = new string[20];
public Form1()
{
InitializeComponent();
}
private void boysButton_Click(object sender, EventArgs e)
{
for (int i = 0; i <= 5; ++i)
{
RandomName();
namesBox.Items.Add(NewName);
}
}
private void girlsButton_Click(object sender, EventArgs e)
{
for (int i = 0; i <= 5; ++i)
{
RandomName();
namesBox.Items.Add(NewName);
}
}
private string ChooseBoys(string[] options)
{
Random rand = new Random();
boys[0] = "Chuck";
boys[1] = "Stewart";
boys[2] = "David";
boys[3] = "Robert";
boys[4] = "Steven";
boys[5] = "Patrick";
boys[6] = "Greg";
boys[7] = "Austin";
boys[8] = "Thomas";
boys[9] = "Dylan";
boys[10] = "Christopher";
boys[11] = "Sean";
boys[12] = "Alexander";
boys[13] = "Tony";
boys[14] = "Topher";
boys[15] = "Lyle";
boys[16] = "Kyle";
boys[17] = "Stonewall";
boys[18] = "Jackson";
boys[19] = "George";
for (int i = 0; i < boys.Length; ++i)
{
int itemNum = rand.Next(boys.Length);
return boys[itemNum];
}
}
private string ChooseGirls(string[] options)
{
Random rand = new Random();
girls[0] = "Susan";
girls[1] = "Katy";
girls[2] = "Chloe";
girls[3] = "Darlene";
girls[4] = "Grace";
girls[5] = "Brianna";
girls[6] = "Maddie";
girls[7] = "Hayden";
girls[8] = "Jaclyn";
girls[9] = "Scarlette";
girls[10] = "Selena";
girls[11] = "Emilia";
girls[12] = "Desiree";
girls[13] = "Carol";
girls[14] = "Melissa";
girls[15] = "Peyton";
girls[16] = "Mary";
girls[17] = "Lori";
girls[18] = "Wendy";
girls[19] = "Claire";
string rg = girls[rand.Next(girls.Length)];
}
private string RandomName(string[] names)
{
for (int i = 0; i <=2; ++i)
{
ChooseBoys();
}
string NewName = names.ToString() + " " + names.ToString();
return NewName;
}
}
}
Aucun commentaire:
Enregistrer un commentaire