コード例 #1
0
 void Calculate(object sender, EventArgs e)
 {
     try
     {
         if (calculateTo.SelectedIndex == -1)
         {
             Alerts.InvalidInput(messageToUser: AppResources.emtpyEquationPickerCalculate);
         }
         else
         {
             if (calculateTo.SelectedIndex == 0)
             {
                 Result.Text = Velocity_VUAT.getFinalVelocity(initialVelocityEntry.Text, accelerationEntry.Text, timeEntry.Text).ToString();
                 //showHow.Text = $"The distance travelled of and object is equal to the velocity of the object times the time it takes. \r\n {Result.Text} = {velocityEntry.Text} * {timeEntry.Text}";
             }
             else if (calculateTo.SelectedIndex == 1)
             {
                 Result.Text = Velocity_VUAT.getInitialVelocity(finalVelocityEntry.Text, accelerationEntry.Text, timeEntry.Text).ToString();
                 //showHow.Text = $"The distance travelled of and object is equal to the velocity of the object times the time it takes. \r\n {Result.Text} = {velocityEntry.Text} * {timeEntry.Text}";      }
             }
             else if (calculateTo.SelectedIndex == 2)
             {
                 Result.Text = Velocity_VUAT.getAcceleration(finalVelocityEntry.Text, initialVelocityEntry.Text, timeEntry.Text).ToString();
                 //showHow.Text = $"The distance travelled of and object is equal to the velocity of the object times the time it takes. \r\n {Result.Text} = {velocityEntry.Text} * {timeEntry.Text}";  }
             }
             else
             {
                 Result.Text = Velocity_VUAT.getTime(finalVelocityEntry.Text, initialVelocityEntry.Text, accelerationEntry.Text).ToString();
             }
         }
     }
     catch (FormatException j)
     {
         Alerts.InvalidInput(messageToUser: AppResources.errorFormatMessage);
     }
     catch (DivideByZeroException j)
     {
         Alerts.InvalidInput(messageToUser: AppResources.errorDivideByZeroMessage);
     }
     catch (Exception j)
     {
         Alerts.InvalidInput(messageToUser: j.Message);
     }
 }
コード例 #2
0
        public void VUAT_Can_Calculate_Time()
        {
            var time = Velocity_VUAT.getTime("200", "100", "50");

            Assert.IsTrue(time == (decimal)2);
        }