After transferring from C to Java I have learned that Java contains many functions that can do the job for you, so to speak, unlike in C where you must do things manually.
I am currently designing an OOP board game, in which multiple players are allowed to pick a playing piece, that represents them throughout the game. I have stored the playing pieces in an array, and then asked the number of players to pick a playing piece. However, they are not allowed to pick the same playing piece as the player before them, for obvious reasons. Therefore, my question is there a function that allows me to remove one of the picked playing pieces from the array or must I do this manually, so to speak. My code is below, if needed:
String[] potential_player_pieces = new String[10]; // Array storing the playing pieces available
potential_player_pieces[0]= "*";
potential_player_pieces[1]= "|";
potential_player_pieces[2]= "?";
potential_player_pieces[3]= "@";
potential_player_pieces[4]= "&";
potential_player_pieces[5]= "¬";
potential_player_pieces[6]= "!";
potential_player_pieces[7]= "%";
potential_player_pieces[8]= "<\n";
String[] player_pieces = new String[players+1]; // String to store the playing pieces that the players have chosen
for (int i=1; i<=players; i++) // Loops to the number of players and asks them what playing piece they want
{
System.out.print("Player " + i + " pick a playing piece:"); // Asks the players the question
for (int j=0; j<=8; j++){
System.out.print(potential_player_pieces[j]); // Displays the possible playing pieces
}
player_pieces[i] = reader.nextLine();//Saves the player chioces to the array made above
}