Exemplo n.º 1
0
        private static void GumballMachineTestDrive(string name, int inventory)
        {
            DesignPatterns.CoreObjects.ProxyPattern.GumballMachine gumballMachine = new DesignPatterns.CoreObjects.ProxyPattern.GumballMachine(inventory, name);
            DesignPatterns.CoreObjects.ProxyPattern.GumballMonitor monitor        = new DesignPatterns.CoreObjects.ProxyPattern.GumballMonitor(gumballMachine);

            Console.WriteLine(monitor.Report());
        }
Exemplo n.º 2
0
        private static void TestRemoteProxyPattern()
        {
            string[] locations = new string[] { "SantaFe", "Boulder", "Seattle", "Atlanta", "Columbia" };
            DesignPatterns.CoreObjects.ProxyPattern.GumballMonitor[] monitors = new DesignPatterns.CoreObjects.ProxyPattern.GumballMonitor[locations.Length];
            Random randomNum = new Random();

            for (int i = 0; i < locations.Length; i++)
            {
                monitors[i] = new DesignPatterns.CoreObjects.ProxyPattern.GumballMonitor(new DesignPatterns.CoreObjects.ProxyPattern.GumballMachineProxy(randomNum.Next(25), locations[i]));

                Console.WriteLine(monitors[i].Report());
                Console.WriteLine();
            }
        }