I have a problem with my homework assignment. I'm not asking for any code whatsoever. All I ask for is some advice on how to implement some parts of the assignment.
The assignment is the following: N number of players (n is given by the user) and a 'box' with letters (A-Z, unspecified number of letters or as it states in the problem: unlimited). Each letter has an index. A=0, B=1, .. , Z=25. Each player receives a random letter. The first player who forms a word of size p >= 3 ( p is given by the user ) with the following property: letter's indexes should be in an arithmetic progression. For instance if p=3, ABC or ZXV is a winning combination.
The program should show at each iteration every player's letters. When one player wins, the program should show the player who won and the winning word.
Suggestions are: using Math.random() and StringBuilder for working with strings.
The way I figured the entry point of this program is asking the user to give the number of players. Afterwards I should generate N number of objects (given a class Player). First stupid question: how do I generate N objects. Something like:
for (int i = 0 ; i < n ; i++) {
Player player1 = new Player();
//how do I allocate the other objects?
}
Is there a way to assign indexes to letters ? All I could think of is generating random letters with something like:
Random r = new Random();
box = new char[9999];
for (int i = 0; i < 9999; i++){
box[i]= (char)(r.nextInt(25)+65); //there are 26 letters and A starts on position 65
}
Any other ideas? Would really appreciate any advice on how to THINK about a solution to this problem.