1
Answer

Random string Array

Ask a question
Joseph

Joseph

13y
2.9k
1


Main Program

The main program will contain three arrays of strings that are provided with initial values:

·         An array of names of the people to insult.

·         An array of verbs to use in the insults.

·         An array of objects for the insults.

The arrays will be provided initial values that will be used to generate the insults. Main will call the method MakeInsults() which will return a string array of insults. Main will call DisplayInsults() to display the insults on the screen. After the insults have been displayed, ask the user if they wish to run the program again. If the user responds with "yes", then clear the screen and run the program again.

MakeInsults()

The method MakeInsults() will be passed the array of names, verbs, and objects as three string array parameters. The minimum number of insults is 5, and the maximum is 100. For each insult generated a random name, verb, and object will be combined into a single insult (as shown in the above example) and stored in an array of insults. After all of the desired insults have been generated, return the array of insults to the main program.

DisplayInsults()

The method DisplayInsults() will be passed the array of insults, and will display them as shown in the above example.

this is what i have so far... i do not know what to do to MakeInsults and Display...help me pls...Thank you

        static void Main(string[] args)
        {
            int iInsults;
            string[] sNames = new string[5] { Bill, Al, John, JD, Ross };
            string[] sVerbs = new string[5] { talks to, runs, licks, flushes, uses };
            string[] sObject = new string[5] { Safeway carts, Microsoft, old mops, dead cows, Vista };
          
            string sAgain;

            Console.Title = "ICA22 - Random Insult Generator";

            do
            {
                Console.WriteLine("{0, 40}", "ICA22 - Random Insult Generator");

                MakeInsults(iInsults, "Enter number of insults to generate: ");
                iInsults
                Display(MakeInsults);

                Console.WriteLine("Run Again? \"yes\" to run again");
                sAgain = Console.ReadLine();
            } 
            while(sAgain == "yes");
            Console.Clear();
            Console.ReadLine();
        }
        static public void MakeInsults(int iInsults, string sPrompt)
        {
            bool bError;
            iInsults = 0;
            Random random = new Random();

            do
            {
                try
                {
                    bError = false;
                    Console.Write("\n{0}", sPrompt);
                    iInsults = int.Parse(Console.ReadLine());

                    if ((iInsults < 5) || (iInsults > 100))
                    {
                        Console.Write("Out of range, Please try again");
                        bError = true;
                    }
                }
                catch (FormatException)
                {
                    Console.Write("An invalid number was entered. Please try again");
                    bError = true;
                }
            }
            while (bError);
        }




Answers (1)