There are two files that we have to submit for this assignment. One of them is G
ID: 3878848 • Letter: T
Question
There are two files that we have to submit for this assignment. One of them is GameDriver.java and the other one is RandGuessGame.java. When I downloaded the two files here they are. I'm totally lost though and need help with what I'm doing.
GameDriver.java
/**
*
* Runs the RandGuessGame. Creates an instance of RandGuessGame and calls upon its methods to conduct the game.
* <br><strong>RandGuessGame methods called in order:</strong><br>
* populateArray<br>
* outputArray (passing true to hide values)<br>
* playerGuess<br>
* getResult<br>
* outputArray (passing false to show all values)<br>
*
*/
public class GameDriver
{
/**
* Main method which creates instance of RandGuessGame and executes its methods.
* @param args Command line arguments (Unused)
*/
public static void main(String[] args)
{
//Generate instance of game
//Conduct game behaviors
}
}
RandGuessGame.java
import java.util.Scanner;
import java.util.Random;
/**
* Class for a simple, randomized guessing game. Five integer values between 1 and MAX_VALUE (inclusive) will be
* generated. Only the first and last will be shown to the player. The player must then guess if the sum
* of all of the numbers is greater than the possible average or not.
*
*/
public class RandGuessGame
{
/**
* Maximum value of randomly generated values.
*/
private static final int MAX_VALUE = 100;
/**
* Number of randomly generated numbers.
*/
private static final int ARR_SIZE = 5;
/**
* Stores randomly generated numbers for game.
*/
private int[] numbers;
/**
* Number the player must guess against, calculated with MAX_VALUE and ARR_SIZE.
*/
private int guessTarget;
/**
* Stores player's guess.
*/
private char guess;
/**
* Stores sum of random values.
*/
private int arraySum;
/**
* Constructor for the RandGuessGame. Creates "numbers" array of size ARR_SIZE to store random values,
* sets arraySum to zero, and calculates value of "guessTarget" by multiplying the amount of numbers by
* half of "MAX_VALUE".
*/
//RandGuessGame Constructor goes here
/**
* Populates the "numbers" array with random numbers between 1 and "MAX_VALUE".
*/
//populateArray method goes here
/**
* Outputs the values in the "numbers" array on a single line, separated by spaces with values hidden
* or all visible based on value of "hidden" parameter.
* @param hidden If true passed will hide middle elements by outputting 'X' instead of the number,
* otherwise will output all elements as normal.
*/
//outputArray method goes here
/**
* Retrieves player's guess using a Scanner. Reads a character and stores into "guess" instance variable.
* Validates that only 'Y' or 'N' are accepted as input. Will continually prompt the user for a guess
* until a 'Y' or 'N' is given.
*/
//playerGuess method goes here
/**
* Checks to see if player's guess was correct and then reports if they are correct or incorrect, then outputs
* sum of array.
*/
//getResult method goes here
}
Please help in any capacity!! Thanks!!!
Explanation / Answer
Hi,
Since you have asked multiple questions here, I am gonna answer only RandGuessGame.java implementation. For other class, please ask seperately. The code for the same is provided below.
// code starts here
// code ends here
Hope it helps!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.