Wheel Of Fortune - Guess Letters That Are Hidden In Characters
Jan 27, 2015
We have to make a wheel of fortune game. Once the above information has been taken, the game can commence. The board should look very similar to the example below if the above input was used. In order to get text to align correctly, use the System.out.format(…) method. It's 14 by 4, so would I use a 2D array? I think I can get the rest done by myself but it's the making of the board I'm having trouble with. Would I need to use a 2D array?
The board is supposed to look something like this to the viewer of the program, but they need to guess the letters that are hidden in the characters. :
These are the hidden values the viewer cannot see and must guess. Therefore, each turn they will guess a letter and the letter will the revealed if the one they said happens to be in the phrase. They will have to get STAR WARS EPISODE IV"
* S T A R * * * W A R S * *
* * E P I S O D E * I V * *
* * * * * * * * * * * * * *
* * * * * * * * * * * * * *
And the concealed letters; are Star Wars episode five a new hope. The # would mean where letters stand. So there first # would be S, the next would be T - and it would eventually spell out STAR WARS EPISODE IV.
So this is the board that's used to display the concealed letter, and there a list of the hidden letters below, like hangman.
import java.util.Scanner;
public class wheelof{
public static Scanner keyboard = new Scanner(System.in);
public static String puzzle1 = "";
public static String puzzle2 = "";
public static String puzzle3 = "";
public static String bonpuzzle = "";
public static String category1 = "";
public static String category2 = "";
package roulette; import java.util.*; public class Roulette { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in);
[Code] ....
This is were its going wrong if i just do a straight "spin" it works but when i try and add additional bets into an array for future comparrison it simply kicks out to my "do" statements says you have quit and acts like i simply hit spin.
I want java coding for roulette wheel selection in genetic algorithm with some explanation. I can't understand the algorithm clearly to implement in my project ...
I'm writing an ESP game code for class. The problem is i cant get it to cycle through the colors after each guess is entered. It stays fixed on the original random number generated.
import java.util.Random; import java.util.Scanner; public class Final1 { String colorInput, computerColor; int computerNum, right, wrong;
[Code] ....
This repeats 10x but the color never changes from the initial random chosen.
This is my code. It is running great until I enter in the final color and hit enter. I get an Array Index out of bounds error, which I show at the bottom. I have fiddled with it, by moving the all answers correct into an if..else statement, hoping it would fix it. Needless to say, it didn't work.
Also, I am trying to figure out how to make the cursor appear in each guess box. It does in the first one, but after I hit enter, I have to click in the box each time to get one.
import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class RobertMaloneChapter17 extends JFrame { //final variables to set the width and height of my frame
[Code] ....
My Errors:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 5 at RobertMaloneChapter17$Listener.actionPerformed(RobertMaloneChapter17.java:67) at javax.swing.JTextField.fireActionPerformed(JTextField.java:508) at javax.swing.JTextField.postActionEvent(JTextField.java:721)
I am creating a hangman code. So the game i am creating is 2 player, first player enters the word and second player guesses. i made the code but i don't know how to restrict the first player from adding random characters into the secret word because for my project the word can only contain letters. so i need making the code so the player 1 can only enter letters.
My code is below:
/** * Auto Generated Java Class. */ import java.util.Scanner; public class Hangman { public static void main(String[] args) { Scanner input= new Scanner(System.in); String player1,player2; int wrongguessamount = 0; //keeps the count of the amount of wrong guesses int correctguessamount = 0; //keeps count of the amount of correct guesses int maxincorrect=6;//makes sure the user cant guess more than 6 times
I am getting a strange error and it almost seems like its not comparing it to the random generated number just the guess that i entered before. Here are my error messages.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at guess.the.numbers.GuessTheNumbers$ButtonHandler.actionPerformed(GuessTheNumbers.java:119) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
I have the following program. In a nutshell, I creates an array of 3 consecutive ints and the user has to guess what those numbers are, knowing that they are between 0 and 7, this is from Head First Java. In the book, the code has a bug that is made on purpose and they challenge you to fix it. As you can see bellow, every time a user's guess matches a int in the array, the NumOfHits is increased by one. When the NumOfHits is 3 (the length of the array) the game finishes.
The bug is that if you guess 1 and 1 is in the array, if you type in 1, 3 times, I will increase the NumOfHits 3 times and end the game as if you had won. To solve the bug, you need to find a way to tell the program that if the user already guessed that number, it should no longer be taken into account and we shouldn't increase the NumOfHits if the same number is provided.
I "fixed" this by searching for the index of the number that matches an int of the array, and changing that index's value to 100, since the user knows that the numbers are between 0 and 7, they will not submit 100.
The result? If the user submits 2 and 2 is in the array, the value of its indexed is replaced by 100, so that if the user submits 2 again it doesn't count as a match.
Please see the comments in the code
import java.io.*; import java.util.Arrays;
class DotCom{ int NumOfHits = 0; int[] LocationCells; public void setLocationCells(int[] locs){ LocationCells = locs;
[Code] .....
The code works, but for some reason, some times I get a ArrayIndexOutOfBoundsException run time error and it appears to be somehow random. This is what I saw on the command line earlier
C:Userspablo.alvarez>java launchDotCom
Enter a number: 3 missed Enter a number: 4 hit Enter a number: 5 hit Enter a number: 7 missed Enter a number: 5 missed Enter a number: 4 missed Enter a number: 3 missed Enter a number: 4 missed Enter a number: 5 missed Enter a number: 6
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 at DotCom.checkYourSelf(launchDotCom.java:16) at DotComGame.startGame(launchDotCom.java:59) at launchDotCom.main(launchDotCom.java:72)
As you can see here, 3 returned 'missed' but 4 and 5 returned hit. Since the numbers are in sequence and are only 3, it makes sense that the last number is 6 (4,5,6). You will then notice that when I submitted 3 and 4 again it returned 'missed' as expected, because the numbers were already matched earlier, but then when I submitted 6, it returned the error seen above.
Sometimes this doesn't happen at all, sometimes it happens at the 2nd guess or third, it appears to be somehow random. I'm familiar with the error message, but I don't see where I'm using an index that doesn't exist in the array. The only time I'm referencing an array index is on
LocationCells[index] = 100;
but the index variable will only hold a value if the int submitted by the user matches on of the values in one of the indexes, so how is it that I'm going over the number of available indexes?
The problem occurs after the user inputs the guess.... it either runs the for loop if guess = numtoguess and reveals the answer even if the user input is wrong.... or it always runs the first if statement in the while loop if guess!= to numtoguess... heres the code
public static void main(String[] args) { String[] Answers = {"yes", "Yes", "No", "no"}; String Name = JOptionPane.showInputDialog(null, "Hello, What is your name?","Random Game", JOptionPane.QUESTION_MESSAGE); String UI = JOptionPane.showInputDialog(null, Name + " do you want to play a game", "Random Game", JOptionPane.QUESTION_MESSAGE);
I have separated characters into an array that can be accessed from any method, however, when I try to compare the inputed guess to the computers random sequence, the counter always comes back as 0 (the comparison occurs in the checkColour method).
Java Code:
package mastermind; import java.util.Scanner; /** * Program Description: play a game of mastermind versus the computer */ public class Mastermind { private static int block1, block2, block3; private static String blockColour1, blockColour2, blockColour3;
[Code] ....
The counter is called colourCorrect.. But I think the problem lies more in me converting the strings (input and computerGuess) into char arrays, as if I output the values at position in the array, I get numbers (but the numbers are not character values from the ascii table).
I'm having some problems with the graphics of my hangman game. The graphic that's supposed to show up on the first guess (the hangman pole) doesn't show up until guess number 2. And on the eighth guess, no graphics show up (I just get a blank frame).
import java.awt.*; import javax.swing.*; public class HangmanFigure extends JPanel { private int guesses; private Image background; public HangmanFigure() { super();
Its a basic program that is played by 2 people. Player one is suppose to type a number and the second player is suppose to guess the number. However after I test it out, and if I guess too low or too high I get stuck in "Your guess is too low, try again." infinite loop, what is wrong.
import java.io.*; class GuessingGame { public static void main (String[] args) throws IOException { BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in)); String firstPlayer, secondPlayer; int firstInput, secondInput; int guessCount = 0;
I can't figure out why my code doesn't work. My task is to replace for example ä=>ae, using this method String.charAt(int index). So here is my code:
public class pich { public static void main(String[] args) { String text = "Die süße Hündin Leica läuft in die Höhle des fülligen Bären "+ "Iliyan (ein Übergrößenträger), der sie zum Teekränzchen eingeladen hat."+ " An ihrem Öhrchen trägt sie modisch eine Ähre."; String textOhneUmlaute = "";
[Code] ....
when I launch my code I get the same String and nothing has changed
I tried this but it only gives me one letter that corresponds to the number
package pkg2911homework.pkg1; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner keys = new Scanner(System.in);
While using generics, are there cases when ? wildcard cannot be replaced with letters [A-Z]? So far , I was able to find only one case, it is when you want to have field pointing on generic instance without making class generic.
class OneClass { private LinkedList<?> myLL; }
In case above, as I understand, you cannot use [A-Z] without generalize OneClass. Are there any other cases, when there is no way except to use ? wildcard instead of letter [A-Z]?
I have devised a simple program that reads a file and then adds up al the integers in the file and print the result, for example if the file had the numbers 1 2 3 4 5 6 7 8 9 10 then the program would print 55
However i have trouble when non integers are put into the file for example if it was 1 2 3 string 4 5 6 test 7 8 9 10
then i get:
Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:840) at java.util.Scanner.next(Scanner.java:1461) at java.util.Scanner.nextInt(Scanner.java:2091) at java.util.Scanner.nextInt(Scanner.java:2050) at Week7.Task3.filereader(Task3.java:25) at Week7.Task3.main(Task3.java:14)
my code is as follows
package testing;
import java.util.*; import java.io.File; import java.io.IOException; public class summingInts { public static void main(String[] args) throws IOException { Scanner textfile = new Scanner(new File("intSum.txt"));
My professor is a man who enjoys making his students form large, but often simple symbols with smaller letters. That might not have clarified much, so let me demonstrate:
VVVVVVV VVVVV VVV V Or... X X X X X X X X X Or lastly... O O O O O O O O
My problem is, that I've always been bad at figuring out the logic behind these.
I can kinda' see it (somewhat) in my head though... I'd need a double for-loop which depend on the sizes, one that monitors the spaces and one that monitors the symbols, with some conditionals in there. How to make symbols like this, using letters, in Java.
I had to write a program for class using the method definition "public static char getNumber(char upperCaseLetter)" It compiles and runs but wont print out my final answer.
import java.util.Scanner; public class Phone_0104730303 { public static char getNumber(char upperCaseLetter) { char return_val = 0;