Hi I'm creating a program that holds three arrays one for the persons last name, one for the points scored and one for the player number, I've got everything done but my ProcessDelete method is changing all of the array instead of instead of just the element where the user enters a players number, I am not sure on how to fix this. Also I have to keep everything in the main program and I have have to keep it as arrays.
Any help would be appreciated please and thanks.
static void ProcessDelete( Int32[] playerNumbers, ref Int32 playerCount, String[] playerLastName, Int32[] playerPoints)
{
Int32[] newArray = new Int32[playerNumbers.Length]; String[] newArray2 = new String[playerLastName.Length]; Int32[] newArray3 = new Int32[playerPoints.Length];
//int index = Array.IndexOf(playerNumbers, 0);
for (int i = 0; i < playerNumbers.Length; i++)
playerNumbers[i] = 0;
for (int i = 0; i < playerLastName.Length; i++)
playerLastName[i] = " ";
for (int i = 0; i < playerPoints.Length; i++)
playerPoints[i] = 0;
}
static void DeletePlayer(Int32[] playerNumbers, String[] playerLastName, Int32[] playerPoints, ref Int32 playerCount, Int32 MAXPLAYERS)
{
int player;// Player number to delete
int playerindex;//index of the player number in Array
if (playerCount < MAXPLAYERS)
{
player = GetPositiveInteger("\nDelete Player: please enter the player's number");
playerindex = GetPlayerIndex(player, playerNumbers, playerCount);
if (playerindex != -1)
{
{
Console.WriteLine("\nDelete Player: Number - {0}, Name - {1}, Points - {2}", playerNumbers[playerindex], playerLastName[playerindex], playerPoints[playerindex]);
Console.WriteLine("Succesfully Deleted");
Console.WriteLine();
ProcessDelete( playerNumbers, ref playerCount, playerLastName, playerPoints);
}
}
else
Console.WriteLine("\nDelete Player: player not found");
}
else
Console.WriteLine("\nDelete Player: the roster is empty");
}
}
}