public Chicken(string name, int age)
if (String.IsNullOrEmpty(value) || String.IsNullOrWhiteSpace(value))
throw new ArgumentException("Name cannot be empty");
if (value < 0 || value > 15)
throw new ArgumentException("Age should be between 0 and 15");
private float CalculateProductPerDay()
return (float)age * 0.01f;
public new string ToString()
return String.Format("Chicken {0} (age {1}) can produce {2} eggs per day.", this.name, this.age, this.CalculateProductPerDay());
public static void Main()
Console.WriteLine("Please enter the chicken's name:");
string name = Console.ReadLine();
Console.WriteLine("Please enter the chicken's age:");
int age = int.Parse(Console.ReadLine());
Chicken chick = new Chicken(name, age);
Console.WriteLine(chick.ToString());
catch (ArgumentException argEx)
Console.WriteLine(argEx.Message);