void ReceiveCall(Telephone source) { if (observer != null) { observer.IncomingCall(this, source.number); } }
public void Calling(Telephone dest) { if (observer != null) { observer.OutgoingCall(this, dest.number); } if (account >= CHARGE) { dest.ReceiveCall(this); account -= CHARGE; } }
static void Main(string[] args) { Telephone t1 = new Telephone("1"), t2 = new Telephone("2"); CallJournal n = new CallJournal(); t1.ObserveRegister(n); t2.ObserveRegister(new FileJournal()); t1.UploadAccount(500); t1.Calling(t2); t1.Calling(t2); t2.Calling(t1); t2.Calling(t1); t1.Calling(t2); t1.Calling(t2); t2.Calling(t1); Console.ReadLine(); }
public void OutgoingCall(Telephone sender, string dest_number) { System.IO.File.AppendAllText("journal.log", "Outgoing call: " + sender + ", source: " + dest_number + "\r\n"); }
public void IncomingCall(Telephone sender, string source_number) { System.IO.File.AppendAllText("journal.log", "Incoming call: " + sender + ", source: " + source_number + "\r\n"); }
public void OutgoingCall(Telephone sender, string dest_number) { Console.WriteLine("Outgoing call: " + sender + ", destination: " + dest_number); }
public void IncomingCall(Telephone sender, string source_number) { Console.WriteLine("Incoming call: " + sender + ", source: " + source_number); }