コード例 #1
0
        /// <summary>
        /// With this main method we  we call out of all sizes the appropriate size
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            IShoesSizeConverter converter = new UsShoeSizeConverter();

            Console.WriteLine("Enter size in centimeters");
            var size = Double.Parse(Console.ReadLine());

            Console.WriteLine("The size in USA for men {0}", converter.GetForCentimeters(size, ShoeCategories.Men).Name);
            IShoesSizeConverter convert = new UkShoeSizeConverter();

            Console.WriteLine("The size in Uk for men {0}", convert.GetForCentimeters(size, ShoeCategories.Men).Name);
            IShoesSizeConverter convrt = new EuroShoeSizeConverter();

            Console.WriteLine("The size in Europe is for men {0}", convrt.GetForCentimeters(size, ShoeCategories.Men).Name);

            IShoesSizeConverter calculating = new UsShoeSizeConverter();

            Console.WriteLine("The size in USA for women {0}", calculating.GetForCentimeters(size, ShoeCategories.Women).Name);
            IShoesSizeConverter calc = new UkShoeSizeConverter();

            Console.WriteLine("The size in Uk for women {0}", calc.GetForCentimeters(size, ShoeCategories.Women).Name);
            IShoesSizeConverter calculate = new EuroShoeSizeConverter();

            Console.WriteLine("The size in Europe is for women {0}", calculate.GetForCentimeters(size, ShoeCategories.Women).Name);
        }
コード例 #2
0
        public HttpResponseMessage Convert([FromUri] double centimeters, [FromUri] string type)
        {
            UsShoeSizeConverter converter = new UsShoeSizeConverter();
            ShoeCategories      category  = ShoeCategories.Women;

            if (type.ToLower().Equals("men"))
            {
                category = ShoeCategories.Men;
            }
            ShoeSize size = converter.GetForCentimeters(centimeters, category);

            return(Request.CreateResponse(HttpStatusCode.OK, size));
        }