using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Demo
{
class Program
{
static void Main(string[] args)
{
Worker stworker = new Worker("8899-1");
stworker.Salary = 9000;
stworker.SetAge(22);
stworker.Name = "the name of stworker!";
Console.WriteLine(stworker.ID);
Console.WriteLine(stworker.Name);
Console.WriteLine(stworker.GetAge());
Console.ReadKey();
}
}
class Worker
{
public string Company;
public string Department;
public string Name;
public readonly string ID;
public string Sex;
private int Age;
public double Salary;
public static int Amount;
public Worker(string id,string name,string sex,int age,string company,string departmen,double salary)
{
this.Age = age;
this.Company = company;
this.Department = departmen;
this.Name = name;
this.Sex = sex;
this.ID = id;
this.Salary = salary;
}
public Worker(string id)
{
this.ID = id;
}
public int GetAge()
{
return Age;
}
public void SetAge(int value)
{
if (value>=18 && value<=65)
{
this.Age = value;
}
else
{
throw new Exception("Worker Age has an error!");
}
}
public Worker()
{
Worker.Amount++;
}
}
}