I'm trying to build a program that has a user guess 4 random pegs in order. it needs to use arrays and methods and i'm struggling mightly... here are some parameters
The structures must be declared as variables in the main() method.
You must write your program so that the number of digits in the random number can be changed. When you submit your answer, there should be 4 digits, but this should be easily changed in the program. Similarly, the number of guesses that the user can make should be defined and be easily changed.
You must not declare any variables outside of your methods, only constant values.
Your program must contain a method called chooseRandomNumber(). The method takes the structure holding the random number as its only argument. The purpose of the method is to fill the number with random digits in the range 0 to 9.
Your program must contain a method called getGuess(). The method takes two arguments, the structure holding the user's guess and the current guess number (i.e. 1st guess, 2nd guess etc). The method will prompt the user to enter a guess and read in the digits of the guess. If the user enters an invalid input, the method will print out an error method and loop back to allow the user to enter the guess again. The method must only return when the structure has been filled with digits.
Your program must contain a method called countBlackPegs(). This takes two arguments, the structure holding the random number and the structure holding the user's guess. The method will return an integer which is the count of the number of digits in the guess that are in the same position as the random number.
Your program must contain a method called countWhitePegs(). This takes two arguments, the structure holding the random number and the structure holding the user's guess. The method will return an integer which is the count of the number of digits in the guess that are in the random number but not in the correct position.
Your main() method will call chooseRandomNumber() to initialise the number chosen by the computer. Then the method will loop. Inside the loop, main() will:
call getGuess() to get the user's move,
call countBlackPegs() and countWhitePegs() to find out how close the user's guess was to the random number.
print out the number of black and white pegs that the user scored with the guess.
The looping will continue until the human guesses the number within the allowed number of guesses, or until the allowed number of guesses has finished. The computer will
print out if the user guessed the number, or not.
Only the getGuess() method can get input from the user. Only the main() and getGuess()
methods can output to the user.