|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace OPG1
|
|
{
|
|
//ФАСАД
|
|
public class Facade
|
|
{
|
|
protected Subsystem1 _subsystem1;
|
|
|
|
protected Subsystem2 _subsystem2;
|
|
|
|
public Facade(Subsystem1 subsystem1, Subsystem2 subsystem2)
|
|
{
|
|
this._subsystem1 = subsystem1;
|
|
this._subsystem2 = subsystem2;
|
|
}
|
|
|
|
public string Operation()
|
|
{
|
|
// типа сложная функциональность
|
|
string result = "Арифметические процессы\n";
|
|
result += "1 число:\n";
|
|
|
|
result += this._subsystem2.operationX();
|
|
result += "\n";
|
|
result += "2 число:\n";
|
|
|
|
result += this._subsystem2.operationY();
|
|
result += "\n";
|
|
result += this._subsystem1.operationN();
|
|
result += this._subsystem2.operationYX();
|
|
result += "\n";
|
|
result += this._subsystem1.operation1();
|
|
result += this._subsystem2.operationXY();
|
|
return result;
|
|
}
|
|
|
|
|
|
}
|
|
public class Subsystem1
|
|
{
|
|
public string operation1()
|
|
{
|
|
return "Добавление\n";
|
|
}
|
|
|
|
public string operationN()
|
|
{
|
|
return "Вычитание\n";
|
|
}
|
|
}
|
|
|
|
public class Subsystem2
|
|
{
|
|
double x = 10;
|
|
double y = 20;
|
|
public double operationX()
|
|
{
|
|
|
|
return x;
|
|
}
|
|
|
|
public double operationY()
|
|
{
|
|
|
|
return y;
|
|
}
|
|
|
|
public double operationXY()
|
|
{
|
|
return x + y;
|
|
}
|
|
public double operationYX()
|
|
{
|
|
return x - y;
|
|
}
|
|
}
|
|
|
|
|
|
class Client
|
|
{
|
|
//легкий интерфейс
|
|
public static void ClientCode(Facade facade)
|
|
{
|
|
Console.Write(facade.Operation());
|
|
}
|
|
}
|
|
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
|
|
Subsystem1 subsystem1 = new Subsystem1();
|
|
Subsystem2 subsystem2 = new Subsystem2();
|
|
Facade facade = new Facade(subsystem1, subsystem2);
|
|
Client.ClientCode(facade);
|
|
Console.ReadLine();
|
|
}
|
|
}
|
|
}
|