Write a Menu class that runs 6 game classes.(Java)

User Generated

lpxbxb123

Computer Science

Description

Please write the program on request.

check the files that I upload that shows you the detailed requirements for each game.

Give you some idea that help to you write the project. Please check the website.

https://www.nvcc.edu/home/dfranssell/CSC200/Charac...

Here you can see the output of the whole project.

Unformatted Attachment Preview

Project Menu: Tuesday February 13 The next 7 projects work together and when finished run as one program. One of the important objectives in these game programs is to solve the problem using methods to break the problem up. Please keep this objective in mind. Write a Menu class that runs 6 game classes. The Menu class has three methods: One for introducing the games program to the client, one that reads the input guaranteeing that the input is between 1 and 7 inclusive, and one for printing the menu. Please use a switch statement to choose one of the 7 choices, and a while loop to allow the client to continue playing games if he wishes. Create 6 more classes that are “stubs” of the six games that you will write as solutions for the next six projects. These stubs can be called from the Menu program, and can be used to test the syntax of the Menu program. Once the Menu program is written and debugged you can start replacing each stub with a game that satisfies the next 6 projects. (Duplicate Character games output on my website) import java.util.Scanner; public class DiscriptiveName{ public static Scanner scan = new Scanner (System.in); // This method controls two while loops public static void discriptiveMethod () throws InterruptedException { introduction () ; int value; String choice = "Yes"; while (choice.equalsIgnorecase ("Yes")) { // outer while loop allows the game to be repeated While ( ) { This inner while loop plays the game. } sleepDemonstration(); choice = shouldıStayInLoop(); } } private static void sleepDemonstration () throws InterruptedException { } private static void introduction () throws InterruptedException { This introduciton method is private. All the methods called from descriptiveMethod () are private."); } private static String shouldeStayInLoop() { String choice; 2 privat System.out.println(spaces + "Would you like to play again?"); System.out.println(spaces + " please enter yes or no "); choice = scan.nextLine(); return choice;}} Tebar | Project Flip a coin: Thursday February 15 (Duplicate Character games output on my website) The game will use the random number generator of the Math class to create a coin flip. The game will ask the user to enter a number for the heads in a row the program will produce. The game will flip the “coin” until the number of heads is reached. There are two versions of the output. The first traces the program as it flips the coin and the other version just prints the number of flips it took. You must solve this problem using methods. I used 5 methods: introduction(), chooseTheImplementation(), giveMeTheTraceImplementation(), giveMeJustTheAnswerImplementation(), and flipACoin(). flipACoin() is the only public method and is called from the class DisplayMenu. flipACoin() calls the other methods which are private. A random coin flip can be generated with the following code: int flip = (int)((Math.random() * 2) + 1). If you want to have commas in the answer use the following code. import java.text.DecimalFormat;// this imports the DecimalFormat class DecimalFormat numberFormat = new DecimalFormat("#####,###,###");// creates an instance of DecimalFormat String stringNumber numberFormat.format(numberOfThrows); // stringNumber is a String representing the int numberOfThrows with commas. See Coin Flip on my website for sample output. = 2 Project High Low Guess: Tuesday February 20 (Duplicate Character games output on my website) This game generates a random number between 1 and 100. The game prompts the user to guess the generated number. The game tells the user if he was low or high. The game allows the user to guess as many times as it takes to guess the number. Guarantee the numbers entered are in an acceptable range. Project Race names: Thursday March 1 (Duplicate Character games output on my website)The game will use the random number generator of the Math class to repeatedly assign to each name a number. These numbers are used by the names to move closer to the finish line. (You can decide the range of the numbers.) Use the code Thread.sleep(1000); to stop the program for a short time as it runs. The argument is in milliseconds. 1000 is one second. By carefully adjusting the number of “\n”, the movement of the names appear to move in a race. I used 7 methods. Here are some additional comments on the NameRace() class: 1) You do not need to name it NameRace. I did not call it that but it would make a good name for the class. 2) The DescriptiveName class that I gave as an example gives an outline for this game. a) There is a public method that is called from the GamesDemo class when this game is picked from the menu. Give this method a name appropriate for the Name Race game. b) There is an introduction method describing the game. I give the text that you can use on my web site. You do not need to use my text but it should be descriptive of the game c) There is a while loop that allows the player to continue playing this game. d) There are other methods in this class that are used. These methods break the code up into logical segments and can be called from the public method to run the code. e) My solution has about 130 lines of code. There are 5 helper methods besides the introduction method that are called to run the game. These are private as is the introduction method. 3) You must understand what the program is to do. From my output on my website it is hard to see how the look. When this game is run the names appear to move from left to right. This involves the String methods making it appear that the three names are moving. The three names move as a group. After each group move I figured out the number of calls to Sysyem.out.println() to make it appear that the names stayed in the same place on the screen. I demonstrate this in the introduction method of the menu class. It looks like this: System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" ); 4) Here is a most basic algorithm: a) print introduction b) Within a loop, allow the client to race as many races as he wishes. game would 3 5) Part two of the algorithm requires a second loop. This means you will use a loop in a loop. (Page 216 gives a while loop in a do-while. DescriptiveMethod() in the DescriptiveName class uses a while loop as the outer loop. You can use either one.) 6) Start thinking about the variables you will need. This is very important! You want to imagine the variables being manipulated as the code is running. a) There are 3 names. I used Jim, Sue, and Tom. Any names will do. Use your own name and think of two other names with the same number of characters. (If the number of characters in the names is different the longer name will have an advantage.) b) Pick a distance for the race. This will be recorded in your program as a number of characters. The length of the race can be about the width of the screen. The display monitor on my class computer does not hold the complete race as I programmed it. (My home computer has a wider screen.) c) In my solution each name needs an integer variable to keep track of its distance and a String variable that will grow in length as the game progresses. d) I used a boolean variable racelsDone as the control variable for the inner while loop. e) These variables are GLOBAL and declared as static variables and placed inside the Name Race class, and for convenience are placed above the methods of the class. When declared as global they are accessible to all the methods of the class. The one public method is called from the Menu class and in its first loop initializes the variables to starting values for a race. If the client wishes to race again, these variables will be re-initialized for the next race. 7) The algorithm for a single race might go like this: a) Set the stage for a race. I have a method that I call to do this. (See the output on my website.) b) While the race is not done: i) For each name: (1) get a number from the random number generator for a move (2) Add this number to the integer value used to keep track of the distance this name has gone (3) Create a string that will have this many characters in it. Most of the characters will be blank with the name at the end. (4) Subtract this number from the integer value used to track the distance this name needs to go and create a string of this many characters. (5) System.out.println() these two strings with the vertical line key. ii) Check to see if a name won the race. If it does, set the boolean variable to true and print the name that won the race. (There could be more than one winner if there is a tie.) 8) I combined items i and ii into one method. This method calls three methods, one for each name that implements item ii. These three methods are almost exactly alike. 9) Besides printing blank lines to make the names appear in the same place on the screen after each move this program also inserts lines that stop the program from running for short periods of time. The line of code that does this is: Thread.sleep(500); This line stops the program for a half second. With an argument of 1000 it would be a second. Programs that use the method sleep() from the Thread class must indicate that an exception may be thrown. The code throws InterruptedException was placed at the end of three of the methods. See the DescriptiveName class for examples of this. I put 2 seconds before the game started and 7 second after each move. Play with it and see how fast you would like your names to move. The sleepDemonstration() method in the DescriptiveName class also demonstrates the random number generator. There it created an integer number from 1 to 6. You can experiment with different values for your NameRace class. I used numbers from 1 to 5. 10) Start writing this solution a little at a time. Get each part you write to compile and run before you go on to the next part. Use System.out.println() to print values of variables to follow the logic of your code. 11) This third game has the end of the race marked for each name. This requires the strings that are printed with each set of moves to maintain their end line as the names progress across the screen. 4 4 Project Draw geometric shapes: Thursday March 8 (Duplicate Character games output on my website) The game displays a menu of 5 geometric shapes: 1) Triangle 2) Diamond 3) Trapezoid 4) Parallelogram 5) Pine Tree I found creating a trapezoid and parallelogram fairly straight forward. A triangle and diamond took some work. The pine tree is a combination of a triangle and two trapezoids. Make the class work without the shapes and then add them one at a time. I used 12 methods. Programing Project 1 in chapter four asked you to create a pattern of stars. The geometric shapes in this project use the same technique used in that problem. Use a for loop nested in a for loop. Use the outer loop to control the number of lines and a second inner for loop to control the stars on any one line. Another way of working with a row of stars is to consider them as strings. A String variable charString can be manipulated in a loop like this: charString = charString + "**" and using the string methods like this: charString = charString.substring(2); 5 Project Guess the characters in a string of words: Tuesday March 20 (Duplicate Character games output on my website) I used 9 methods. I broke the problem into small pieces. I used a method to solve each of the pieces. Some of the methods were very short and some took some work. The algorithm for this problem requires the following 7 steps to be performed: 1) Print an introduction 2) Read an input string 3) Check for legal characters in the input string. I only allowed characters from the alphabet and the blank character. 4) Create an answer string of question marks and a string that indicates the characters that have been used. 5) Read a legal character. 6) Place a legal character in the answer string. 7) Determine if all the characters have been found. Steps 5 through 7 are in a loop. I used a method to solve each of these steps. I encourage you first to work through this algorithm with sample input to demonstrate to your satisfaction that it does solve the problem. Then solve each step with a method. The one public method will call these methods to solve the problem. Remember the String class has a method contains() that returns true or false depending on whether the string contains the string passed in as an argument. Example: String str = "the string"; str.contains("t"); will return true because string str has a t in it. 6 Project Stack of boxes: Thursday March 29 (Duplicate Character games output on my website) Write a sixth game program using the random number generator to generate six integer numbers. Use them to indicate one of six boxes. The program builds a stack of these six boxes. The stack must be built in a proper order. Boxes 1, 2, and 3 are on the bottom and box 4 cannot be placed unless box 1 and 2 are already there. Box 5 cannot be placed unless box 2 and 3 are in place. Box 6 can only be placed if box 4 and 5 are in place. If the random number given is for a box without the proper boxes in place then the pyramid must start over. This process can be seen in the sample output on my website. I used 21 methods. These methods made the class easy to follow. Thirteen of the methods created the thirteen possible output combinations of boxes. The algorithm for this problem requires the following operations to be performed: 1) Pick an implementation of either tracing the boxes as they are created or going directly to a solution. 2) A while loop controls the next three steps. 3) Pick a box 4) Determine if this box can be placed 5) Place a box I used 6 boolean variables each one representing a box. A switch statement called one of 6 methods depending on the random number given for a box. These six methods analyzed the current stack of boxes and determined which one of the 13 box combinations to call.
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Related Tags