Beispiel #1
0
 void ReceiveCall(Telephone source)
 {
     if (observer != null)
     {
         observer.IncomingCall(this, source.number);
     }
 }
Beispiel #2
0
 public void Calling(Telephone dest)
 {
     if (observer != null)
     {
         observer.OutgoingCall(this, dest.number);
     }
     if (account >= CHARGE)
     {
         dest.ReceiveCall(this);
         account -= CHARGE;
     }
 }
Beispiel #3
0
        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();
        }
Beispiel #4
0
 public void OutgoingCall(Telephone sender, string dest_number)
 {
     System.IO.File.AppendAllText("journal.log", "Outgoing call: " + sender + ", source: " + dest_number + "\r\n");
 }
Beispiel #5
0
 public void IncomingCall(Telephone sender, string source_number)
 {
     System.IO.File.AppendAllText("journal.log", "Incoming call: " + sender + ", source: " + source_number + "\r\n");
 }
Beispiel #6
0
 public void OutgoingCall(Telephone sender, string dest_number)
 {
     Console.WriteLine("Outgoing call: " + sender + ", destination: " + dest_number);
 }
Beispiel #7
0
 public void IncomingCall(Telephone sender, string source_number)
 {
     Console.WriteLine("Incoming call: " + sender + ", source: " + source_number);
 }