Exemple #1
0
        /// <summary>
        /// Adapter pattern by Class approach
        /// </summary>
        private void ClassAdapterTest()
        {
            ISocketAdapter socketAdapter = new SocketObjectAdapter();
            Volt           v3            = this.GetVolt(socketAdapter, 3);
            Volt           v12           = this.GetVolt(socketAdapter, 12);
            Volt           v120          = this.GetVolt(socketAdapter, 120);

            Console.WriteLine("v3 volts using Object Adapter is " + v3.GetVolts());
            Console.WriteLine("v12 volts using Object Adapter is " + v12.GetVolts());
            Console.WriteLine("v120 volts using Object Adapter is " + v120.GetVolts());
        }
 /// <summary>
 /// Function to convert volt
 /// </summary>
 /// <param name="v">volt v as a parameter</param>
 /// <param name="i">i as a parameter</param>
 /// <returns>returns new instance of Volt with converting Volt</returns>
 private Volt ConvertVolt(Volt v, int i)
 {
     return(new Volt(v.GetVolts() / i));
 }