예제 #1
0
        private void AltUnitsChoice_SelectedIndexChanged(object sender, EventArgs e)
        {
            ResetFailure();
            ComboBox Selector = (ComboBox)sender;
            AltUnits NewUnits = DecideAltUnits((string)Selector.SelectedItem);

            try
            {
                if (CurrentAltUnits == NewUnits)
                {
                    return;
                }
                if (!RwyElevationInput.Text.Equals(string.Empty))
                {
                    double CurrElev = double.Parse(RwyElevationInput.Text);
                    if (CurrentAltUnits == AltUnits.FEET)
                    {
                        RwyElevationInput.Text = Math.Round(InputCleaner.FeetToMeters(CurrElev)).ToString();
                    }
                    else
                    {
                        RwyElevationInput.Text = Math.Round(InputCleaner.MetersToFeet(CurrElev)).ToString();
                    }
                }
            } catch { FailedUnitsConversion(); }
            CurrentAltUnits = NewUnits;
        }
예제 #2
0
        private void WeightUnitsChoice_SelectedIndexChanged(object sender, EventArgs e)
        {
            ResetFailure();
            ComboBox     Selector = (ComboBox)sender;
            PrimaryUnits NewUnits = DecideUnits((string)Selector.SelectedItem);

            try
            {
                if (NewUnits == CurrentUnits)
                {
                    return;
                }
                if (!WeightInput.Text.Equals(string.Empty))
                {
                    double CurrWeight = double.Parse(WeightInput.Text);
                    if (CurrentUnits == PrimaryUnits.METRIC)
                    {
                        WeightInput.Text = Math.Round(InputCleaner.KilogramsToPounds(CurrWeight)).ToString();
                    }
                    else
                    {
                        WeightInput.Text = Math.Round(InputCleaner.PoundsToKilograms(CurrWeight)).ToString();
                    }
                }
            } catch { FailedUnitsConversion(); }
            CurrentUnits = NewUnits;
        }
예제 #3
0
        public void Should_Remove_AllWhiteSpace()
        {
            var input    = "   I    +    I    ";
            var expected = "I + I";

            Assert.AreEqual(expected, InputCleaner.Clean(input));
        }
예제 #4
0
        public void Passing_Null_Gives_Empty_String()
        {
            string input    = null;
            var    expected = string.Empty;

            Assert.AreEqual(expected, InputCleaner.Clean(input));
        }
예제 #5
0
파일: Program.cs 프로젝트: corywheeler/Calc
        public static void Main(string[] args)
        {
            string expression = string.Empty;

            if (args.Length > 0)
            {
                expression = InputCleaner.Clean(args[0]);
                Console.WriteLine("{0}", new RomanCalculator(expression).Result());
            }
            else
            {
                Console.WriteLine("usage: Calc I + I");
            }
        }
예제 #6
0
        private void ComputeBtn_Click(object sender, EventArgs e)
        {
            ResetFailure();
            ResetOutput();
            PrimaryUnits       Units         = DecideUnits((string)WeightUnitsChoice.SelectedValue);
            AltUnits           AltitudeUnits = DecideAltUnits((string)AltUnitsChoice.SelectedValue);
            FlapsSetting       Flaps         = DecideFlapsSetting((string)FlapsSettingSel.SelectedValue);
            LandingSpeedValues BaseValues    = new LandingSpeedValues {
                Units = Units, Flaps = Flaps,
            };
            bool ConvertSuccess = double.TryParse(OATInput.Text, out double OAT);

            ConvertSuccess &= double.TryParse(WeightInput.Text, out double WeightDouble);
            if (!ConvertSuccess)
            {
                FailedToClean(); return;
            }
            BaseValues.OAT    = (int)Math.Round(OAT);
            BaseValues.Weight = (int)Math.Round(WeightDouble);

            // Compute Landing
            bool CleanSuccess = InputCleaner.CleanedLandingSpeeds(BaseValues, out LandingSpeedValues CleanedLandingVals);

            if (!CleanSuccess)
            {
                FailedToClean(); return;
            }
            LandingComputation LandingComp = new LandingComputation(CleanedLandingVals);

            if (LandingComp.Failed)
            {
                FailedToCompute(); return;
            }

            // Display landing data
            DisplayLandingData(LandingComp.Output);

            TakeoffSpeedValues TakeOffValues = new TakeoffSpeedValues();

            // ALT Units, AntiIce, Runway HDG, Wind HFG, Wind Speed, Elevation, RWY Conditions
            TakeOffValues.BasicVals = CleanedLandingVals;
            bool ConvertValsSuccess = double.TryParse(RwyElevationInput.Text, out double RwyElev);

            ConvertValsSuccess &= double.TryParse(RwyHdgInput.Text, out double RwyHdg);
            double WindHdg = 0;
            double WindSpd = 0;

            try
            {
                string[] WindInfo = RwyWindInput.Text.Split('/');
                ConvertValsSuccess &= double.TryParse(WindInfo[0], out WindHdg);
                ConvertValsSuccess &= double.TryParse(WindInfo[1], out WindSpd);
            }
            catch { FailedToCleanTO(); return; }
            if (!ConvertValsSuccess)
            {
                FailedToCleanTO(); return;
            }
            TakeOffValues.Elevation  = (int)Math.Round(RwyElev);
            TakeOffValues.RunwayHdg  = (int)Math.Round(RwyHdg);
            TakeOffValues.WindHdg    = (int)Math.Round(WindHdg);
            TakeOffValues.WindSpd    = (int)Math.Round(WindSpd);
            TakeOffValues.Conditions = DecideRunwayConditions((string)RwyCondSel.SelectedItem);
            TakeOffValues.AntiIce    = DeIceOnCheckbox.Checked;

            CleanSuccess = InputCleaner.CleanedTakeoffSpeeds(TakeOffValues, out TakeoffSpeedValues CleanedTakeOffVals);
            if (!CleanSuccess)
            {
                FailedTakeoffComputation(); return;
            }

            TakeoffComputation TakeoffComp = new TakeoffComputation(CleanedTakeOffVals);

            if (TakeoffComp.Failed)
            {
                FailedTakeoffComputation(); return;
            }

            // Display Takeoff Data
            DisplayTakeoffData(TakeoffComp.Output);
            Success();
        }
예제 #7
0
 public void clearInputSearch()
 {
     InputCleaner.clearInputs(searchID, searchKhoa, searchClass, searchNgayCap, searchHetHan, searchRealname, searchBirthday, searchSex, searchSDT, searchLocation);
 }