Question Description
I’m working on a Java project and need support to help me understand better.
All of the instructions are within the Java doc header comments and the example output is attached in a file.
Please make the code as simple as possible only using the provided imported tools(Random, Scanner, etc).
import java.util.Random;
import java.util.Scanner;
public class MonsterCollector {
/*
* This method is for trying to catch a monster of your very own!
* Generate a random number from 1 to 5 inclusive. If the user did NOT guess this number, they caught the monster.
* Add that monster to the next null spot in the myMonster array. If they were successful
* in catching the monster print “Congratulations, you caught [monster]!”
* otherwise print “You almost had it, but the monster escaped.”
* If monster, myMonsters, or rand is null, return before doing ANYTHING else in the method.
*
* @param userGuess – user guess between 1 and 5
* @param monster – monster retrieved from getMonster
* @param myMonsters – array of monsters user has caught
* @param rand – random number generator
*/
public static void catchMonster(int userGuess, String monster, String[] myMonsters, Random rand) {
}
/*
* This method is for retrieving your next monster to encounter.
* Search through the array starting at index 0 until you find an index that is not null;
* this will be the monster you encounter. Set that monsters index to null and return
* the monster.
*
* @param monsters – the array of monster left to encounter
* @return String – next monster to encounter. If monsters is null, return null.
* If you search through the entire monsters array, and all indexes are null, return null.
*/
public static String getMonster(String[] monsters) {
return null;
}
/*
* Count the number of monsters the user caught, and print it to the console.
* If the user caught all the monsters, they are the master! Otherwise,
* they must continue to train.
* The number of monsters the user caught will be the number of non-null elements in the user’s monster array,
* while the total possible monsters is the size of the myMonsters array.
* (See assignment page for example output)
*
* @param myMonsters – monsters the user has caught
*/
public static void printResult(String[] myMonsters) {
}
/*
* This is the main method.
* Config.MONSTERS is an array provided in Config.java, full of cool monsters to encounter!
* Create a new array the same size as Config.MONSTERS, then copy all the entries from Config.MONSTERS
* into your new array.(Hint: A loop could be useful here)
* Welcome your user to the game, and start your game loop. The game ends when the user has encountered
* all monsters in our monsters array.
* First get the monster we are going to encounter. If the monster is null, inform the user there are no more
* monsters to encounter, and end the game. If the monster is not null, prompt the user for a number between
* 1 and 5 and begin the encounter. If the user input is out of range of 1 – 5, prompt the user again until we
* receive correct input.
* When the game ends, print the results.
* (See assignment page for example output)
*
* @param args unused
*/
public static void main(String[] args) {
}
}
//Below is the Config.java file that needs to be utilized in the main program along with the seed that cannot be changed.
Config.java file
public class Config {
public static final String[] MONSTERS = new String[] {“pikamoo”,”bulbaroar”,”chubaboo”,”nubat”,”qualimer”};
public static final int SEED = 365;
}