static void Main(string[] args)
        {
            RoundHole hole      = new RoundHole(5);
            SquarePeg sp        = new SquarePeg(2);
            SPAdapter spAdapter = new SPAdapter(sp.GetWidth(), sp);

            Console.WriteLine(hole.fits(spAdapter));
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var hole = new RoundHole(5);
            var rpeg = new RoundPeg(5);

            Console.WriteLine("Hole Fits: " + hole.fits(rpeg));

            var small_sqpeg = new SquarePeg(5);
            var large_sqpeg = new SquarePeg(10);
            // The next line wont compile
            // Console.WriteLine("Hole Fits" + hole.fits(small_sqpeg));

            var small_sqpeg_class_adapter     = new SquarePegClassAdapter(small_sqpeg);
            var large_sqpeg_class_adapter     = new SquarePegClassAdapter(large_sqpeg);
            var small_sqpeg_Interface_adapter = new SquarePegInterfaceAdapter(small_sqpeg);
            var large_sqpeg_Interface_adapter = new SquarePegInterfaceAdapter(large_sqpeg);

            Console.WriteLine("Hole Fits: " + hole.fits(small_sqpeg_class_adapter));
            Console.WriteLine("Hole Fits: " + hole.fits(large_sqpeg_class_adapter));
            Console.WriteLine("Hole Fits: " + hole.fits(small_sqpeg_Interface_adapter));
            Console.WriteLine("Hole Fits: " + hole.fits(large_sqpeg_Interface_adapter));
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            RoundHole hole = new RoundHole {
                Radius = 15
            };
            SquarePegAdapter adapter = new SquarePegAdapter(new SquarePeg {
                Width = 10
            });

            if (hole.fits(adapter))
            {
                Console.WriteLine("Кол забить можно");
            }
            else
            {
                Console.WriteLine("Кол забить нельзя");
            }
        }