static void Main(string[] args) { ILanguage language = new CSharpLanguage(); var freelance = new FreelanceProgrammer(language); freelance.DoWork(); freelance.EarnMoney(); Console.WriteLine(); var corporate = new CorporateProgrammer(language); corporate.DoWork(); corporate.EarnMoney(); }
static void Main(string[] args) { // создаем нового программиста, он работает с с++ Programmer freelancer = new FreelanceProgrammer(new CPPLanguage()); freelancer.DoWork(); freelancer.EarnMoney(); // пришел новый заказ, но теперь нужен c# freelancer.Language = new CSharpLanguage(); freelancer.DoWork(); freelancer.EarnMoney(); Programmer inCompany = new CorporateProgrammer(new JavaScriptLanguage()); inCompany.DoWork(); inCompany.EarnMoney(); Console.Read(); }