Example #1
0
        static void Main(string[] args)
        {
            double miles = 7;
            double feet  = 7260;

            Console.WriteLine("Eric's Distance Converter");

            DistanceConverter converter = new DistanceConverter();

            miles = converter.GetDouble("Miles");
            feet  = converter.ToFeet(miles);

            Console.WriteLine("The no. of miles = " + miles);
            Console.WriteLine("The no. of feet = " + feet);

            feet  = converter.GetDouble("Feet");
            miles = converter.ToMiles(feet);

            Console.WriteLine("The no. of feet = " + feet);
            Console.WriteLine("The no. of miles = " + miles);
        }
Example #2
0
        /// <summary>
        /// Task 4.1 Create a Converter and check that it converts between
        /// miles and feet using double numbers
        /// </summary>
        public static void TestDistanceConverter()
        {
            double miles = 1;
            double feet  = 0;

            Console.WriteLine("Georgia's Distance Converter");

            DistanceConverter converter = new DistanceConverter();

            int choice = 3;

            string[] choices = new string[]
            {
                "1. Convert Miles to Feet",
                "2. Convert Feet to Miles",
                "3. Quick Test"
            };

            do
            {
                choice = SimpleIO.GetChoice(choices);

                if (choice == 1)
                {
                    miles = converter.GetDouble("Miles");
                    feet  = converter.ToFeet(miles);

                    Console.WriteLine("The no of miles = " + miles);
                    Console.WriteLine("The no of feet = " + feet);
                }
                else if (choice == 2)
                {
                    feet  = converter.GetDouble("Feet");
                    miles = converter.ToMiles(feet);

                    Console.WriteLine("The no of feet = " + feet);
                    Console.WriteLine("The no of miles = " + miles);
                }
            } while (choice != 3);
        }