using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Soldier
{
int physical;
public Soldier(int physical)
{
this.Physical = physical;
}
public Soldier()
{
}
public int Physical { get => physical; set => physical = value; }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Master
{
int physical;
public Master(int physical)
{
this.Physical = physical;
}
public int Physical { get => physical; set => physical = value; }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
delegate void AutoTask(Master m);
delegate void AutoTask<T>(T t);
class Program
{
static void Main(string[] args)
{
Master m = new Master(10);
AutoTask<Master> at = Task01;
at += Task02;
at += Task03;
at(m);
Soldier s = new Soldier();
AutoTask<Soldier> at2 = Task01S;
at2 += Task02S;
at2(s);
}
public static void Task01(Master m)
{
if (m.Physical >= 5)
{
m.Physical -= 5;
}
else
{
return;
}
Console.WriteLine("任务一开启!");
Console.WriteLine("任务一完成!");
}
public static void Task02(Master m)
{
if (m.Physical >= 5)
{
m.Physical -= 5;
}
else
{
return;
}
Console.WriteLine("任务二开启!");
Console.WriteLine("任务二完成!");
}
public static void Task03(Master m)
{
if (m.Physical >= 5)
{
m.Physical -= 5;
}
else
{
return;
}
Console.WriteLine("任务三开启!");
Console.WriteLine("任务三完成!");
}
private static void Task02S(Soldier t)
{
Console.WriteLine("任务二开启!");
Console.WriteLine("任务二完成!");
}
private static void Task01S(Soldier t)
{
Console.WriteLine("任务一开启!");
Console.WriteLine("任务一完成!");
}
}