I need one method added to my game programs so that my demo will run.?
-
I get an eclipse error that the method play() is undefined for my game classes and I do not know how to add the method play to them. Also if you spot anything wrong with my demo could you let me know, I haven't run it yet because of the errors so I'm not sure if it would run them. Here is my demo: import java.util.Scanner; public class GameDemo { static Scanner scan = new Scanner(System.in); public static void main(String[] args) { int GameChoice = 0; DiceGame Game1 = new DiceGame(); DiceGame2 Game2 = new DiceGame2(); DiceGame3 Game3 = new DiceGame3(); DiceGame4 Game4 = new DiceGame4(); RandomGuess Game5 = new RandomGuess(); SkillGuess Game6 = new SkillGuess(); while(GameChoice != 7) { menu(); GameChoice = input(); switch(GameChoice) { case 1: Game1.play(); break; case 2: Game2.play(); break; case 3: Game3.play(); break; case 4: Game4.play(); break; case 5: Game5.play(); break; case 6: Game6.play(); break; case 7: System.out.println("Closing the demo."); break; default: break; } } } public static int input() { int gameChoice = 0; while(true) { gameChoice = scan.nextInt(); if(gameChoice == 0) menu(); if(gameChoice > 0 && gameChoice <= 7) break; else System.out.println("Try again, 1 through 7 only. 0 for the menu again."); } return gameChoice; } public static void menu() { System.out.println("1) Throw a particular die number a certain number of times in a row."); System.out.println("2) Build a chart displaying the randomness of the 6 die numbers."); System.out.println("3) Throw a given pattern of six dice."); System.out.println("4) Find the percent difference for each die number from the average, given a certain number of throws."); System.out.println("5) Guess the number between 1 and 100"); System.out.println("6) Guess a five digit number."); System.out.println("7) Quit playing."); System.out.println("Please choose one of the 7 choices."); } } Here is DiceGame2: import java.util.Scanner; public class DiceGame2 { public static void main(String[] args) { final int DICE_FACE_COUNT = 6; Scanner keyboard = new Scanner (System.in); int numberOfTimes; int [] diceValues = new int[DICE_FACE_COUNT]; String response = "yes"; while (response.compareTo("yes") == 0) { for (int i = 0; i < diceValues.length; i++) { diceValues[i] = 0; } System.out.println("Please enter the number of times that"); System.out.print("you would like to throw the dice: "); numberOfTimes = keyboard.nextInt(); System.out.println("The chart showing " + numberOfTimes + " throws of the dice:"); while(numberOfTimes > 0) { int result = (int)(DICE_FACE_COUNT * Math.random()); diceValues[result]++; numberOfTimes--; } for (int i = 0; i < diceValues.length; i++) { System.out.print(i + 1 + " "); for (int astr = 0; astr < diceValues[i]; astr++) { System.out.print("*"); } System.out.println(); } System.out.println("\nWould you like to play the game again?"); System.out.print("Please enter (yes/no) "); response = keyboard.next(); System.out.println(); } } } Here is DiceGame 3: import java.util.Scanner; public class DiceGame3 { public static Scanner keyboard = new Scanner(System.in); public static String diceSeries() { String series; System.out.println("Please enter a series of 6 dice that " + "you would like the computer to duplicate"); series = keyboard.next(); return series; } public static String throwPattern() { String pattern = ""; for (int i = 0; i < 6; i++) { pattern += "" + (int)(Math.random() * 6 + 1); } return pattern; } public static int numberOfThrows(String pattern) { int count = 0; while (!pattern.equals(throwPattern())) { count++; } return count; } public static void printResult(int numberOfThrows, String pattern) { System.out.println("It took " + numberOfThrows + " throws to get the pattern " + pattern + " to appear"); } public static void main(String[] args) { String pattern; int throwsNumber; String again = "yes"; while (again.equals("yes")) { pattern = diceSeries(); throwsNumber = numberOfThrows(pattern); printResult(throwsNumber, pattern); System.out.println("\nWould you like to play the game again?"); System.out.print("Please enter (yes/no) "); again = keyboard.next(); System.out.println(); } } }
-
Answer:
OK. This may take a while. I'll email you the codes once I'm done.
Tiger at Yahoo! Answers Visit the source
Related Q & A:
- I need help deciding between graduate programs, forestry, or parks and rec.Best solution by Yahoo! Answers
- What exactly will I need to run two 12" subs through my car?Best solution by crutchfield.com
- What kind of amp would I need for these speakers to run optimally?Best solution by Yahoo! Answers
- What exactly do I need to run an XBox 360?Best solution by wiki.answers.com
- What kinds of learning dissabilitys are there? I seem to not understand some simple things and need one to one?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.