using System;
namespace Fine
{
public delegate void PlayGameFine(object senter,System.EventArgs e);
public class Supervisor
{
public Supervisor()
{
Console.WriteLine("generate a supervisor object");
}
public void DockSalary(object senter,System.EventArgs e)
{
Employee employee=(Employee)senter;
Console.WriteLine("你又玩游戏,我要扣你的薪水,看你小子能省多少");
employee.Salary-=500;
}
}
public class Employee
{
public event PlayGameFine fine;
private int salary;
public Employee()
{
Console.WriteLine("generate a employee object");
this.salary=50000;
}
public int Salary
{
set
{
this.salary=value;
}
get
{
return this.salary;
}
}
public void PlayGame()
{
if(fine!=null)
{
fine(this,new System.EventArgs());
}
}
}
public class Game
{
public static void Main(string[] args)
{
Supervisor supervisor=new Supervisor();
Employee employee=new Employee();
employee.fine+=new PlayGameFine(supervisor.DockSalary);
employee.PlayGame();
Console.WriteLine("现在该员工还剩下:" +employee.Salary);
Console.WriteLine("场景结束");
Console.ReadLine();
}
}
}
namespace Fine
{
public delegate void PlayGameFine(object senter,System.EventArgs e);
public class Supervisor
{
public Supervisor()
{
Console.WriteLine("generate a supervisor object");
}
public void DockSalary(object senter,System.EventArgs e)
{
Employee employee=(Employee)senter;
Console.WriteLine("你又玩游戏,我要扣你的薪水,看你小子能省多少");
employee.Salary-=500;
}
}
public class Employee
{
public event PlayGameFine fine;
private int salary;
public Employee()
{
Console.WriteLine("generate a employee object");
this.salary=50000;
}
public int Salary
{
set
{
this.salary=value;
}
get
{
return this.salary;
}
}
public void PlayGame()
{
if(fine!=null)
{
fine(this,new System.EventArgs());
}
}
}
public class Game
{
public static void Main(string[] args)
{
Supervisor supervisor=new Supervisor();
Employee employee=new Employee();
employee.fine+=new PlayGameFine(supervisor.DockSalary);
employee.PlayGame();
Console.WriteLine("现在该员工还剩下:" +employee.Salary);
Console.WriteLine("场景结束");
Console.ReadLine();
}
}
}