using System;
//Professor Class
public class Professor
{
//[Code] Define Fields
public string strProfessorName;
private int _age;
public int Age
//[Code] Define Property Age
//Make sure Age is between 18 and 70
//If Age violates the rule, set the default value as 30
get
return _age;
}
set
if (value>=18 && value <= 70)
_age = value;
else
_age = 30;
//[Code] Define Property Degree
private string _degree;
public string Degree
//Make sure Degree has at least three letters
//If Degree violates the rule, set the defaul value as "Master"
return _degree;
if
(value.Length >= 3)
_degree = value;
_degree = "Master";
//[Code] Constructor
public Professor()
public class Program
public static void Main()
//[Code] Create object ProfessorLiu
Professor Professor1 = new Professor();
// ProfessorName: Liu
Professor1.strProfessorName = "Liu";
// Age: 99
Professor1.Age = 99;
// Degree: PhD
Professor1.Degree = "PhD";
}}