using System;
//static field, static method, goto statment , try catch
//csc static_field.cs
namespace ex_static_field {
public class Player
{
public string id;
public string name;
public static int p_id;
public Player()
{
Console.WriteLine("Blank Constructor evoked");
}
public Player(string name, string id)
{
this.name = name;
this.id = id;
Console.WriteLine("Overloaded Constructor evoked");
}
public static int AddPlayer()
{
return ++p_id;
}
}
class MainClass : Player
{
static void Main()
{
start:
Console.WriteLine("New Number of Players: {0}",Player.p_id);
Console.Write("Enter the player's name: ");
string name = Console.ReadLine();
Console.Write("Enter the player's ID: ");
string id = Console.ReadLine();
if ((id != "" )&(name !=""))
{
try
{
// Create and configure the employee object:
Player e = new Player(name, id);
Console.Write("Enter the current number of employees: ");
string n = Console.ReadLine();
Player.p_id = Int32.Parse(n);
Player.AddPlayer();
// Display the new information:
Console.WriteLine("Name: {0}", e.name);
Console.WriteLine("ID: {0}", e.id);
Console.WriteLine("New Number of Players: {0}",Player.p_id);
}
catch(Exception e){
Console.WriteLine("Wrong Data and " + e);
goto start;
}
}
Console.ReadLine();
}
}
}//end of namenapace