I created a player class and I am trying to use my player class with my menu driven player program but I keep getting the error The best overload method for Assignment_7.Program.ProcessCreate(int, string, string, int, int, Assignment_7.Player, ref in, int) has some invalid arguments with my methods I am trying to use with my menu
Any help would be appreciated.
const Int32 MAXPLAYERS = 23;
Int32[] playerNumbers = new Int32[MAXPLAYERS];
String[] playerLastNames = new String[MAXPLAYERS];
Int32[] playerPoints = new Int32[MAXPLAYERS];
Int32 playerCount = 0;
char menuItem;
Console.WriteLine("Welcome to the player system...\n");
menuItem = GetMenuItem();
while (menuItem != 'X')
{
ProcessMenuItem(menuItem, playerNumbers, playerLastNames, playerPoints, ref playerCount, MAXPLAYERS);
menuItem = GetMenuItem();
}
Console.WriteLine("\nThank you, goodbye");
Console.ReadLine();
}
static char GetMenuItem()
{
char menuItem;
DisplayMenu();
menuItem = char.ToUpper(char.Parse(Console.ReadLine()));
while (menuItem != 'C'
&& menuItem != 'L' && menuItem != 'X' && menuItem != 'R' && menuItem != 'U' && menuItem != 'D')
{
Console.WriteLine("\nError - Invalid menu item");
DisplayMenu();
menuItem = char.ToUpper(char.Parse(Console.ReadLine()));
}
return menuItem;
}
static void DisplayMenu()
{
Console.WriteLine("\nPlease pick an item:");
Console.WriteLine("C - Create Player");
Console.WriteLine("R - Retrive Player");
Console.WriteLine("U - Update Player");
Console.WriteLine("D - Delete Player");
Console.WriteLine("L - List Players");
Console.WriteLine("X - Exit");
}
static void ProcessMenuItem(Char menuItem, Int32[] playerNumbers, String[] playerLastNames,
Int32[] playerPoints, ref Int32 playerCount, Int32 MAXPLAYERS)
{
switch (menuItem)
{
case 'C':
ProcessCreate(playerNumbers, playerLastNames, playerPoints, ref playerCount, MAXPLAYERS);
break;
case 'L':
ProcessList(playerNumbers, playerLastNames, playerPoints, playerCount);
break;
case 'R':
ProcessRetrive(playerNumbers, playerLastNames, playerPoints, playerCount, MAXPLAYERS);
break;
case 'U':
ProcessUpdate(playerNumbers, playerLastNames, playerPoints, playerCount, MAXPLAYERS);
break;
case 'D':
DeletePlayer( playerNumbers, playerLastNames, playerPoints, ref playerCount, MAXPLAYERS);
break;
}
}
static void ProcessCreate(Int32[] playerNumbers, String[] playerLastNames,
Int32[] playerPoints, ref Int32 playerCount, Int32 MAXPLAYERS)
{
Int32 number, points;
String lastName;
if (playerCount < MAXPLAYERS)
{
number = GetPositiveInteger("\nCreate Player: please enter the player's number");
if (GetPlayerIndex(number, playerNumbers, playerCount) == -1)
{
lastName = GetString("\nCreate Player: please enter the player's last name");
points = GetPositiveInteger("\nCreate Player: please enter the player's points");
InsertPlayer(number, lastName, points, playerNumbers, playerLastNames, playerPoints, ref playerCount);
Console.WriteLine("\nCreate Player: Number - {0}, Name - {1}, Points - {2}, created successfully", number, lastName, points);
Console.WriteLine();
}
else
Console.WriteLine("\nCreate Player: the player number already exists");
}
else
Console.WriteLine("\nCreate Player: the player roster is already full");
}
static void InsertPlayer(Int32 number, String lastName, Int32 points,
Int32[] playerNumbers, String[] playerLastNames, Int32[] playerPoints,
ref Int32 playerCount)
{
Int32 insertIndex, shiftCount;
insertIndex = GetInsertIndex(number, playerNumbers, playerCount);
for (shiftCount = playerCount; shiftCount > insertIndex; shiftCount--)
{
playerNumbers[shiftCount] = playerNumbers[shiftCount - 1];
playerLastNames[shiftCount] = playerLastNames[shiftCount - 1];
playerPoints[shiftCount] = playerPoints[shiftCount - 1];
}
playerNumbers[insertIndex] = number;
playerLastNames[insertIndex] = lastName;
playerPoints[insertIndex] = points;
playerCount++;
}
static Int32 GetInsertIndex(Int32 playerNumber, Int32[] playerNumbers,
Int32 playerCount)
{
Int32 index = 0;
bool found = false;
while (index < playerCount && found == false)
if (playerNumbers[index] > playerNumber)
found = true;
else
index++;
return index;
}
static Int32 GetPlayerIndex(Int32 playerNumber,
Int32[] playerNumbers, Int32 playerCount)
{
Int32 index = 0;
bool found = false;
while (index < playerCount && found == false)
if (playerNumbers[index] == playerNumber)
found = true;
else
index++;
if (found == false)
index = -1;
return index;
}
static void ProcessList(Int32[] playerNumbers, String[] playerLastNames,
Int32[] playerPoints, Int32 playerCount)
{
if (playerCount > 0)
{
Console.WriteLine("\n{0,7} {1,-25}{2,6}\n", "Number", "Last Name", "Points");
for (Int32 player = 0; player < playerCount; player++)
Console.WriteLine("{0,7} {1,-25}{2,6}", playerNumbers[player], playerLastNames[player], playerPoints[player]);
}
else
Console.WriteLine("\nList Players: the roster is empty");
}
static Int32 GetPositiveInteger(String prompt)
{
Int32 n;
Console.WriteLine(prompt);
n = Int32.Parse(Console.ReadLine());
while (n < 0)
{
Console.WriteLine("\nError: enter positive value");
Console.WriteLine(prompt);
n = Int32.Parse(Console.ReadLine());
}
return n;
}
static String GetString(String prompt)
{
String returnString;
Console.WriteLine(prompt);
returnString = Console.ReadLine();
while (returnString == "")
{
Console.WriteLine("\nError: must enter keyboard data");
Console.WriteLine(prompt);
returnString = Console.ReadLine();
}
return returnString;
}
static void ProcessRetrive(Int32[] playerNumbers, String[] playerLastName, Int32[] playerPoints, Int32 playerCount, Int32 MAXPLAYERS)
{
int player;
int playerindex;
if (playerCount < MAXPLAYERS)
{
player = GetPositiveInteger("\nRetrieve Player: please enter the player's number");
playerindex = GetPlayerIndex(player, playerNumbers, playerCount);
if (playerindex != -1)
{
{
Console.WriteLine("\nRetrive Player: Number - {0}, Name - {1}, Points - {2}", playerNumbers[playerindex], playerLastName[playerindex], playerPoints[playerindex]);
Console.WriteLine();
}
}
else
Console.WriteLine("\nRetrieve Player: player not found");
}
else
Console.WriteLine("\nRetrieve Player: the roster is empty");
}
static void ProcessUpdate(Int32[] playerNumbers, String[] playerLastName, Int32[] playerPoints, Int32 playerCount, Int32 MAXPLAYERS)
{
int player;
int playerindex;
String lastName;
int points;
if (playerCount < MAXPLAYERS|| playerCount == MAXPLAYERS)
{
player = GetPositiveInteger("\nUpdate Player: please enter the player's number");
playerindex = GetPlayerIndex(player, playerNumbers, playerCount);
if (playerindex != -1)
{
lastName = GetString("\nUpdate Player: please enter the player's updated last name");
points = GetPositiveInteger("\nUpdate Player: please enter the player's updated points");
playerLastName[playerindex] = lastName;
playerPoints[playerindex] = points;
}
else
Console.WriteLine("\nUpdate Player: the player number does not exists");
}
else
Console.WriteLine("\nUpdate Player: the player does not exist in the roster");
}
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; index < playerLastName.Length; index++)
playerLastName[i] = " ";
for (int i = 0; i < 10; 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;
int playerindex;
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");
}
}
}