-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathBaseSubject.cs
More file actions
36 lines (32 loc) · 760 Bytes
/
BaseSubject.cs
File metadata and controls
36 lines (32 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Eryan
{
public class BaseSubject : Subject
{
List<Observer> observers = new List<Observer>();
Event e;
public void registerObserver(Observer o)
{
foreach (Observer observer in observers)
{
if (observer.Equals(o))
return;
}
observers.Add(o);
}
public void removeObserver(Observer o)
{
observers.Remove(o);
}
public void notifyObservers()
{
foreach (Observer observer in observers)
{
observer.update(e);
}
}
}
}