public Form1() { InitializeComponent(); Lits_button = new List <My_button>(); up = new My_button(0, -1); down = new My_button(0, 1); left = new My_button(-1, 0); right = new My_button(1, 0); Lits_button.Add(up); Lits_button.Add(down); Lits_button.Add(left); Lits_button.Add(right); my_but = new ConcreteObserver(button6, Lits_button); my_but1 = new ConcreteObserver(button5, Lits_button); my_but2 = new ConcreteObserver(button7, Lits_button); up.Attach(my_but); down.Attach(my_but); left.Attach(my_but); right.Attach(my_but); my_but.Activ_text(); up.Attach(my_but1); down.Attach(my_but1); left.Attach(my_but1); right.Attach(my_but1); my_but1.Activ_text(); up.Attach(my_but2); down.Attach(my_but2); left.Attach(my_but2); right.Attach(my_but2); my_but2.Activ_text(); }
public void Detach(Observer observer) { observers.Remove(observer); }
public void Attach(Observer observer) { observers.Add(observer); }