Using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace ConsoleApplication1
{
public class Singleon
{
public Singleon ()
{
//
//TODO: Add constructor logic here
//
}
}
public Interface Xh_subject
{
void Smile (observers obs);
}
public Interface Observers
{
void Say ();
}
public class Xh:xh_subject
{
private ArrayList all;
public XH ()
{
all = new ArrayList ();
}
#region Xh_subject Member
public void Smile (observers obs)
{
all. ADD (OBS);
}
#endregion
public void Cry ()
{
Console.WriteLine ("Cry and all!");
foreach (observers obs in all)
{
Obs.say ();
}
}
}
public class Wo:observers
{
private string name;
public wo (string name, Xh_subject xh_sub)
{
this.name = name;
Xh_sub.smile (this);
}
#region Observers member
public void Say ()
{
Console.WriteLine ("Say something take care of her!");
}
#endregion
}
public class Jz:observers
{
private string name;
public JZ (string name, Xh_subject xh_sub)
{
this.name = name;
Xh_sub.smile (this);
}
#region Observers member
public void Say ()
{
Console.WriteLine ("I fu le you!");
}
#endregion
}
class Client_factory
{
[STAThread]
static void Main (string[] args)
{
Consoleapplication1.xh h = new XH ();
Xh_subject sub = h;
consoleapplication1.wo me = new Wo ("devil", sub);
CONSOLEAPPLICATION1.JZ j = new JZ ("N_man", sub);
h.cry ();
}
}
}