Hello DaniWeb, i`m a new member here, so greeting to you.
As the topic title says i`m in bit of a problem, so a little help would be appreciated, I am as newbie as it get`s when talking about JAVA, so here it is.
I`m trying to figuere out a game with 3 players that get random letters from a ALPHABET, and when it finds a word formed in a DICTIONARY it declares that player the winner.
Here is what I have so far:
public class Main {
static Random noroc = new Random();
public static void main(String[] args) {
final char[] ALFABET = {'a', 'b'};
final String[] DICTIONAR = {"b", "a"};
int n = ALFABET.length;
StringBuilder player1 = new StringBuilder();
StringBuilder player2 = new StringBuilder();
StringBuilder player3 = new StringBuilder();
boolean state = false;
while (state == false) {
if (state == false) //PLAYER 1
{
int r = noroc.nextInt(n);
char h = ALFABET[r];
player1.append(h);
System.out.println("Player 1 got the letters:" + player1 + "\n");
}
This is just the part for player 1, player 2 would include a similar if. My problem is how do I compare the last x characters in player1 to words in DICTIONAR.
Thanks in advanced, and looking foreward to being a member of this very constructive forum.