Example #1
0
        public static void oneLiner_1_Step()
        {
            p("\n-=-=-=-=-=-=-=-=-\nBasic Syntax: 1 step conversion | One Liner, 12.5 feet to meters");

            double feetToMeters = new UnitOf.Length().FromFeet(12.5).ToMeters(); //12.5 feet to meters = 3.81 meters

            pt(feetToMeters);                                                    //prints 3.81 as 12.5 feet to meters = 3.81 meters
        }
Example #2
0
        public static void setThenConvert_2_Steps()
        {
            p("\n-=-=-=-=-=-=-=-=-\nBasic Syntax: 2 step conversion | set then convert to any unit of the measurement, 5 meters to feet and inches");

            UnitOf.Length meters = new UnitOf.Length().FromMeters(5); //Instantiate UnitOf.Length meters and set "meters" variable as 5 meters
            double        feet   = meters.ToFeet();                   //5 meters to feet = ~16.404 feet
            double        inches = meters.ToInches();                 //5 meters to inches = ~196.85 inches

            pt(feet);                                                 //prints 16.404 as 5 meters to feet = ~16.404 feet
            pt(inches);                                               //prints 196.85 as 5 meters to inches = ~196.85 inches
        }
Example #3
0
        public static void getFromTypeAndValue()
        {
            p("\n-=-=-=-=-=-=-=-=-\nBasic Syntax: Get the passed in \"from\" type constant and value | 5 meters is passed in");

            UnitOf.Length length   = new UnitOf.Length().FromMeters(5); //Instantiate UnitOf.Length length and set "length" variable as 5 meters
            string        fromType = length.GetTypeConstantPassed();    //"M" is returned as meters is the set "from" unit, "M" represents the contant of meters.
            object        fromVal  = length.GetValuePassed();           //5 is returned as 5 meters is the set "from" unit and value.

            pt(fromType);                                               //prints "M" as meters is the current set from type
            pt(fromVal);                                                //prints 5 as the current set from value to meters was passed in as 5. Object is returned because other measurements DataType can pass in values other than numbers.
            pt(new UnitOf.DataType(fromVal).ToDouble(-1));              //prints 5 - shameless plug for UnitOf.DataType(), convert the fromVal of type Object to a double. If convertin to double fails, defailt to -1.
        }
Example #4
0
        public static void instantiateSetThenConvert_3_Steps()
        {
            p("\n-=-=-=-=-=-=-=-=-\nBasic Syntax: 3 step conversion | instantiate, set, then convert, 3 inches to feet and meters");

            UnitOf.Length length = new UnitOf.Length(); //Instantiate UnitOf.Length length
            length.FromInches(3);                       //Set length variable as 3 inches
            double feet   = length.ToFeet();            //3 inches to feet = 0.25 feet
            double meters = length.ToMeters();          //3 inches to meters = 0.0762 meters

            pt(feet);                                   //prints 0.25 as 3 inches to feet = 0.25 feet
            pt(meters);                                 //prints 0.0762 as 3 inches to meters = 0.0762 meters
        }
Example #5
0
        public static void setThenConvertTwice()
        {
            p("\n-=-=-=-=-=-=-=-=-\nBasic Syntax: 2 step conversion reassigning \"from\" | set then convert, 5 meters to feet and inches then update from value to be 12.5 inches. Then convert to meters and inches");

            UnitOf.Length len     = new UnitOf.Length().FromMeters(5); //Instantiate UnitOf.Length len and set "len" variable as 5 meters
            double        feet1   = len.ToFeet();                      //5 meters to feet = ~16.404 feet
            double        inches1 = len.ToInches();                    //5 meters to inches = ~196.85 inches

            len.FromFeet(12.5);                                        //Set len variable as 12.5 feet
            double meters2 = len.ToMeters();                           //12.5 feet to meters = 3.81 meters
            double inches2 = len.ToInches();                           //12.5 feet to inches = 150 inches

            pt(feet1);                                                 //prints 16.404 as 5 meters to feet = ~16.404 feet
            pt(inches1);                                               //prints 196.85 as 5 meters to inches = ~196.85 inches
            pt(meters2);                                               //prints 3.81 as 12.5 feet to meters = 3.81 meters
            pt(inches2);                                               //prints 150 as 12.5 feet to inches = 150 inches
        }