using System;
namespace Friendly_Bot
{
internal class Program
{
private static string[] Greetings = { "Hello, you have a", "Hey, you have a", "Hi, you have a" };
private static string[] Compliments = { "cool", "fashionable", "stylish" };
private static string[] Garments = { "coat.", "dress.", "shirt.", "skirt.", "suit.", "swimsuit." };
private static string[] Farewells = { "ADIOS!", "BYE!", "BYE-BYE!", "FAREWELL!", "GOODBYE!" };
private static string Greeting;
private static string Compliment;
private static string Garment;
private static string Farewell;
private static string Message;
private static void Main(string[] args)
{
GenerateMessage();
}
private static void GenerateMessage()
{
int i = new Random().Next(1, 11);
//20% chance of including a farewell in the message.
if (i < 3)
{
Greeting = Greetings[new Random().Next(0, Greetings.Length)];
Compliment = Compliments[new Random().Next(0, Compliments.Length)];
Garment = Garments[new Random().Next(0, Garments.Length)];
Farewell = Farewells[new Random().Next(0, Farewells.Length)];
Message = Greeting + " " + Compliment + " " + Garment + " " + Farewell;
Console.WriteLine(Message);
Console.ReadLine();
}
//80% chance of NOT including a farewell in the message.
else
{
Greeting = Greetings[new Random().Next(0, Greetings.Length)];
Compliment = Compliments[new Random().Next(0, Compliments.Length)];
Garment = Garments[new Random().Next(0, Garments.Length)];
Message = Greeting + " " + Compliment + " " + Garment;
Console.WriteLine(Message);
Console.ReadLine();
}
}
}
}
This code will piece together a random message with the contents in 4 separate arrays: Greetings, Compliments, Garments, Farewells.
There is a 20% chance of the randomly generated message including a farewell at the end of the message. There is an 80% chance for the message not to include a farewell exclamation in the message.
How can I clean this code up and make it produce the same product, but more efficiently? Any help is greatly appreciated! :)