3、式。现在有这样两个类:Microsoft和Investor,如下图所示:图3UML静态图示例它们的实现如下:WORD资料下载可编辑专业技术资料分享public class Microsoft{ private Investor _investor; private String _symbol; private double _price; public void Update() { _investor.SendData(this); } public Investor Investor { get {
4、return _investor; } set { _investor = value; }WORD资料下载可编辑专业技术资料分享 } public String Symbol { get { return _symbol; } set { _symbol = value; } } public double Price { get { return _price; } set { _price = value; } }}public class Investor{WOR
5、D资料下载可编辑专业技术资料分享 private string _name; public Investor(string name) { this._name = name; } public void SendData(Microsoft ms) { Console.WriteLine("Notified {0} of {1}'s " + "change to {2:C}", _name, ms.Symbol,ms.Price); }}简单的客户端实现:class Program{WORD资料下载可编辑专业技
6、术资料分享 static void Main(string[] args) { Investor investor = new Investor("Jom"); Microsoft ms = new Microsoft(); ms.Investor = investor; ms.Symbol = "Microsoft"; ms.Price = 120.00; ms.Update(); Console.ReadLine(); }WORD资料下载可编辑专业技术资料分享}运