public override void Send(string msg, Person person) { if (LandlordPerson == person) { RenterPerson.Notify(msg); } else if (RenterPerson == person) { LandlordPerson.Notify(msg); } }
static void Main(string[] args) { ManagerMediator managerMediator = new ManagerMediator(); LandlordPerson landlord = new LandlordPerson(managerMediator, new Apartament { Address = "Московская 3", Price = 12000 }); landlord.Apartament.Owner = landlord; RenterPerson renter = new RenterPerson(managerMediator); managerMediator.LandlordPerson = landlord; managerMediator.RenterPerson = renter; landlord.Send("Сдаю в аренду квартиру " + "| Address: " + landlord.Apartament.Address); renter.Send("Готов арендовать квартиру!"); landlord.ToRent(renter); Console.ReadLine(); }
public abstract void ToRent(LandlordPerson landlord, RenterPerson renter);
public override void ToRent(LandlordPerson landlord, RenterPerson renter) { landlord.Apartament.Renter = renter; renter.Apartament = landlord.Apartament; Console.WriteLine("Сделка успешно удалась!"); }