Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace Broker mode
{
public abstract class Person {
public string Name {get; set;}
public string Condition {get; set;}
public abstract void Getpartner (person P);
}
public class Men:person
{
Public Mediator M
{
Get
Set
}
Public men (string name, string condition, mediator m)
{
This. name = name;
This. Condition = Condition;
THIS.M = m;
M.men = this;
}
public override void Getpartner (person p)
{
This.m.getpartner (THIS,P);
}
}
public class Women:person
{
Public Mediator M
{
Get Set
}
Public women (String name,string condition, mediator m)
{
This. name = name;
This. Condition = Condition;
THIS.M = m;
M.women = this;
}
public override void Getpartner (person p)
{
This.m.getpartner (this, p);
}
}
public class Mediator
{
Public women women {get; set;}
Public men's Men {get; set;}
public void Getpartner (person W,person m)
{
if (w.gettype () = = M.gettype ())
{
Console.WriteLine ("I'm not gay!") ");
}
else if (w.condition = = m.condition)
{
Console.WriteLine (w.name+ "and" +m.name+ "are perfect Match");
}
Else
{
Console.WriteLine (W.name + "and" + M.name + "no good match");
}
}
}
Class Program
{
static void Main (string[] args)
{
Mediator m = new Mediator ();
Person Zhangsan = new Men ("Zhang San", "5", m);
Person Lisi = new Men ("John Doe", "5", m);
Person Lili = new Women ("Lily", "5", m);
Person Lihua = new Women ("Li Hua", "6", m);
Zhangsan.getpartner (Lisi);
Zhangsan.getpartner (Lihua);
Lisi.getpartner (Lili);
Console.readkey ();
}
}
}
Mediator Mode C # (Matchmaker edition)