using System;
namespace Example62
{
public class SoccerPlayer
{
private int playerNumber;
public int PlayerNumber
{
get { return playerNumber; }
}
public void promptForNumber()
{
try
{
Console.Write("Enter player's number: ");
playerNumber = int.Parse(Console.ReadLine());
}
catch (FormatException e)
{
throw(e);
}
}
}
///
/// Summary description for Class1.
///
class Class1
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
SoccerPlayer sp = new SoccerPlayer();
bool isGoodNumber = false;
while (!isGoodNumber)
{
try
{
sp.promptForNumber();
isGoodNumber = true;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
Console.WriteLine("Player " + sp.PlayerNumber);
}
}
}