Question: c# practice problem. random number generator using lists instead of arrays Declare 2 class level integer Lists to hold the random numbers. There are 7

c# practice problem. random number generator using lists instead of arrays

  1. Declare 2 class level integer Lists to hold the random numbers.

    • There are 7 whole numbers chosen for the player.

    • There are 6 whole numbers chosen as the winning numbers.

  2. Add the following user defined methods to your code:

    a) private void GenerateRandomNumbers(List numberList)

    • This method accepts one integer List as a parameter Lists are passed by reference, hence there is no need to pass back the List to the calling method.

    • This method will loop through the List generating random numbers between 1 and 49.

    • Add code that checks that the number has not been used before. b) private string BuildDisplayString(List numberList)

    • Inside this method, loop through the List that is passed in and add each element to a string variable.

    • Return this string to the calling method where it will display it to the appropriate label. c) privateintCompareTwoArrays(Listlist1,Listlist2)

    • This method will loop through one of the Lists. Each element of this List will checked against all elements of the second List checking for a match.

    • If a match is found, increment a variable holding the number of matching values when done, this value is passed back to the calling method.

  3. Code the btnPlayer_Click( ) event handler method:

    • This event will require you to generate random numbers for the player and display these numbers to

      the appropriate label.

    • Use the appropriate methods you defined above.

  4. Code the btnComputer_Click( ) event handler method:

    • This event will require you to generate random numbers for the computer the winning numbers

      and display them to the appropriate label.

    • The event will also determine the number of matching numbers between the winning numbers and the

      players numbers. Display this value to the appropriate label.

    • Use the appropriate methods you defined above

c# practice problem. random number generator using lists instead of arrays Declare

windows forms app .net framework

2. Declare 2 class level integer Lists to hold the random numbers. There are 7 whole numbers chosen for the player. There are 6 whole numbers chosen as the winning numbers. 3. Add the following user defined methods to your code: a) private void Generate RandomNumbers (List numberList) This method accepts one integer List as a parameter - Lists are passed by reference, hence there is no need to pass back the List to the calling method. This method will loop through the List generating random numbers between 1 and 49. Add code that checks that the number has not been used before. b) private string BuildDisplayString (List numberList) Inside this method, loop through the List that is passed in and add each element to a string variable. Return this string to the calling method - where it will display it to the appropriate label. c) private int Compare TwoArrays (List listi, List list2) . This method will loop through one of the Lists. Each element of this List will checked against all elements of the second Listo checking for a match. If a match is found, increment a variable holding the number of matching values - when done, this value is passed back to the calling method. 4. Code the btnPlayer_Click() event handler method: This event will require you to generate random numbers for the player and display these numbers to the appropriate label. Use the appropriate methods you defined above. 5. Code the btnComputer_Click() event handler method: This event will require you to generate random numbers for the computer - the 'winning numbers - and display them to the appropriate label. The event will also determine the number of matching numbers between the winning numbers and the player's numbers. Display this value to the appropriate label. Use the appropriate methods you defined above. 6. Other requirement: Comments at the very least, your name) Variable names that follow naming conventions Proper code spacing (tabbing)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!